From 5bf1bfd784f3143e383f77d42b5c04752fd473e7 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 15 Aug 2023 15:00:27 -0700 Subject: [PATCH] other elements --- library/alloc/src/vec/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 9654e1d6997..6c238fd2d0c 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1222,7 +1222,7 @@ impl Vec { /// does not materialize a reference to the underlying slice, and thus the returned pointer /// will remain valid when mixed with other calls to [`as_ptr`] and [`as_mut_ptr`]. /// Note that calling other methods that materialize mutable references to the slice, - /// or references to specific elements you are planning on accessing through this pointer, + /// or mutable references to specific elements you are planning on accessing through this pointer, /// may still invalidate this pointer. /// See the second example below for how this guarantee can be used. /// @@ -1244,10 +1244,10 @@ impl Vec { /// /// ```rust /// unsafe { - /// let mut v = vec![0]; + /// let mut v = vec![0, 1, 2]; /// let ptr1 = v.as_ptr(); /// let _ = ptr1.read(); - /// let ptr2 = v.as_mut_ptr(); + /// let ptr2 = v.as_mut_ptr().offset(2); /// ptr2.write(2); /// // Notably, the write to `ptr2` did *not* invalidate `ptr1`: /// let _ = ptr1.read();