Skip to content

Commit 5bf1bfd

Browse files
committed
other elements
1 parent 10fc06f commit 5bf1bfd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/alloc/src/vec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ impl<T, A: Allocator> Vec<T, A> {
12221222
/// does not materialize a reference to the underlying slice, and thus the returned pointer
12231223
/// will remain valid when mixed with other calls to [`as_ptr`] and [`as_mut_ptr`].
12241224
/// Note that calling other methods that materialize mutable references to the slice,
1225-
/// or references to specific elements you are planning on accessing through this pointer,
1225+
/// or mutable references to specific elements you are planning on accessing through this pointer,
12261226
/// may still invalidate this pointer.
12271227
/// See the second example below for how this guarantee can be used.
12281228
///
@@ -1244,10 +1244,10 @@ impl<T, A: Allocator> Vec<T, A> {
12441244
///
12451245
/// ```rust
12461246
/// unsafe {
1247-
/// let mut v = vec![0];
1247+
/// let mut v = vec![0, 1, 2];
12481248
/// let ptr1 = v.as_ptr();
12491249
/// let _ = ptr1.read();
1250-
/// let ptr2 = v.as_mut_ptr();
1250+
/// let ptr2 = v.as_mut_ptr().offset(2);
12511251
/// ptr2.write(2);
12521252
/// // Notably, the write to `ptr2` did *not* invalidate `ptr1`:
12531253
/// let _ = ptr1.read();

0 commit comments

Comments
 (0)