We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1207b7f + f9752b4 commit 2065c4bCopy full SHA for 2065c4b
library/core/src/ptr/mod.rs
@@ -342,10 +342,12 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
342
/// ```
343
/// use std::ptr;
344
///
345
-/// let mut array = [0, 1, 2, 3];
+/// let mut array: [i32; 4] = [0, 1, 2, 3];
346
+///
347
+/// let array_ptr: *mut i32 = array.as_mut_ptr();
348
-/// let x = array[0..].as_mut_ptr() as *mut [u32; 3]; // this is `array[0..3]`
-/// let y = array[1..].as_mut_ptr() as *mut [u32; 3]; // this is `array[1..4]`
349
+/// let x = array_ptr as *mut [i32; 3]; // this is `array[0..3]`
350
+/// let y = unsafe { array_ptr.add(1) } as *mut [i32; 3]; // this is `array[1..4]`
351
352
/// unsafe {
353
/// ptr::swap(x, y);
0 commit comments