Skip to content

Commit 533e678

Browse files
committed
docs: fix unused-mut
Signed-off-by: Martin Kröning <[email protected]>
1 parent 81f5c0d commit 533e678

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/volatile_ptr/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
///
1010
/// struct Example { field_1: u32, field_2: u8, }
1111
/// let mut value = Example { field_1: 15, field_2: 255 };
12-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
12+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
1313
///
1414
/// // construct a volatile reference to a field
1515
/// let field_2 = map_field!(volatile.field_2);
@@ -23,7 +23,7 @@
2323
/// #[repr(packed)]
2424
/// struct Example { field_1: u8, field_2: usize, }
2525
/// let mut value = Example { field_1: 15, field_2: 255 };
26-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
26+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
2727
///
2828
/// // Constructing a volatile reference to an unaligned field doesn't compile.
2929
/// let field_2 = map_field!(volatile.field_2);

src/volatile_ptr/operations.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
/// use volatile::VolatilePtr;
103103
///
104104
/// let mut value = 42;
105-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
105+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
106106
/// volatile.write(50);
107107
///
108108
/// assert_eq!(volatile.read(), 50);
@@ -125,7 +125,7 @@ where
125125
/// use volatile::VolatilePtr;
126126
///
127127
/// let mut value = 42;
128-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
128+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
129129
/// volatile.update(|val| val + 1);
130130
///
131131
/// assert_eq!(volatile.read(), 43);
@@ -148,7 +148,7 @@ where
148148
/// use volatile::VolatilePtr;
149149
///
150150
/// let mut value = 42;
151-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
151+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
152152
/// volatile.write(50);
153153
/// let unwrapped: *mut i32 = volatile.as_raw_ptr().as_ptr();
154154
///
@@ -174,7 +174,7 @@ where
174174
///
175175
/// struct Example { field_1: u32, field_2: u8, }
176176
/// let mut value = Example { field_1: 15, field_2: 255 };
177-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
177+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
178178
///
179179
/// // construct a volatile pointer to a field
180180
/// let field_2 = unsafe { volatile.map(|ptr| NonNull::new(core::ptr::addr_of_mut!((*ptr.as_ptr()).field_2)).unwrap()) };
@@ -187,7 +187,7 @@ where
187187
/// use volatile::VolatilePtr;
188188
///
189189
/// let mut value = 5;
190-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
190+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
191191
///
192192
/// // DON'T DO THIS:
193193
/// let mut readout = 0;
@@ -224,7 +224,7 @@ where
224224
/// use volatile::VolatilePtr;
225225
///
226226
/// let mut value: i16 = -4;
227-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
227+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
228228
///
229229
/// let read_only = volatile.restrict::<ReadOnly>();
230230
/// assert_eq!(read_only.read(), -4);
@@ -245,7 +245,7 @@ where
245245
/// use volatile::VolatilePtr;
246246
///
247247
/// let mut value: i16 = -4;
248-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
248+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
249249
///
250250
/// let read_only = volatile.read_only();
251251
/// assert_eq!(read_only.read(), -4);
@@ -266,10 +266,10 @@ where
266266
///
267267
/// struct Example { field_1: u32, field_2: u8, }
268268
/// let mut value = Example { field_1: 15, field_2: 255 };
269-
/// let mut volatile = unsafe { VolatilePtr::new((&mut value).into()) };
269+
/// let volatile = unsafe { VolatilePtr::new((&mut value).into()) };
270270
///
271271
/// // construct a volatile write-only pointer to `field_2`
272-
/// let mut field_2 = map_field!(volatile.field_2).write_only();
272+
/// let field_2 = map_field!(volatile.field_2).write_only();
273273
/// field_2.write(14);
274274
/// // field_2.read(); // compile-time error
275275
/// ```

src/volatile_ptr/unstable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'a, T, A> VolatilePtr<'a, [T], A> {
155155
/// let mut dst = [0, 0];
156156
/// // the `Volatile` type does not work with arrays, so convert `dst` to a slice
157157
/// let slice = &mut dst[..];
158-
/// let mut volatile = unsafe { VolatilePtr::new(NonNull::from(slice)) };
158+
/// let volatile = unsafe { VolatilePtr::new(NonNull::from(slice)) };
159159
/// // Because the slices have to be the same length,
160160
/// // we slice the source slice from four elements
161161
/// // to two. It will panic if we don't do this.
@@ -212,8 +212,8 @@ impl<'a, T, A> VolatilePtr<'a, [T], A> {
212212
/// use core::ptr::NonNull;
213213
///
214214
/// let mut byte_array = *b"Hello, World!";
215-
/// let mut slice: &mut [u8] = &mut byte_array[..];
216-
/// let mut volatile = unsafe { VolatilePtr::new(NonNull::from(slice)) };
215+
/// let slice: &mut [u8] = &mut byte_array[..];
216+
/// let volatile = unsafe { VolatilePtr::new(NonNull::from(slice)) };
217217
/// volatile.copy_within(1..5, 8);
218218
///
219219
/// assert_eq!(&byte_array, b"Hello, Wello!");
@@ -347,7 +347,7 @@ impl<A> VolatilePtr<'_, [u8], A> {
347347
/// use core::ptr::NonNull;
348348
///
349349
/// let mut vec = vec![0; 10];
350-
/// let mut buf = unsafe { VolatilePtr::new(NonNull::from(vec.as_mut_slice())) };
350+
/// let buf = unsafe { VolatilePtr::new(NonNull::from(vec.as_mut_slice())) };
351351
/// buf.fill(1);
352352
/// assert_eq!(unsafe { buf.as_raw_ptr().as_mut() }, &mut vec![1; 10]);
353353
/// ```

src/volatile_ref.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ where
207207
/// use volatile::VolatileRef;
208208
///
209209
/// let mut value: i16 = -4;
210-
/// let mut volatile = VolatileRef::from_mut_ref(&mut value);
210+
/// let volatile = VolatileRef::from_mut_ref(&mut value);
211211
///
212212
/// let read_only = volatile.restrict::<ReadOnly>();
213213
/// assert_eq!(read_only.as_ptr().read(), -4);
@@ -228,7 +228,7 @@ where
228228
/// use volatile::VolatileRef;
229229
///
230230
/// let mut value: i16 = -4;
231-
/// let mut volatile = VolatileRef::from_mut_ref(&mut value);
231+
/// let volatile = VolatileRef::from_mut_ref(&mut value);
232232
///
233233
/// let read_only = volatile.read_only();
234234
/// assert_eq!(read_only.as_ptr().read(), -4);
@@ -250,7 +250,7 @@ where
250250
/// #[derive(Clone, Copy)]
251251
/// struct Example { field_1: u32, field_2: u8, }
252252
/// let mut value = Example { field_1: 15, field_2: 255 };
253-
/// let mut volatile = VolatileRef::from_mut_ref(&mut value);
253+
/// let volatile = VolatileRef::from_mut_ref(&mut value);
254254
///
255255
/// let write_only = volatile.write_only();
256256
/// // write_only.as_ptr().read(); // compile-time error

0 commit comments

Comments
 (0)