about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNixon Enraght-Moony <nixon.emoony@gmail.com>2022-10-24 15:01:58 +0100
committerNixon Enraght-Moony <nixon.emoony@gmail.com>2022-10-24 15:01:58 +0100
commit674cd6125da1277af2d864b7d4e637c0a73f142c (patch)
treee6058e434c205ce136cbf8ebd2bfa009fa1af6f9
parent1481fd964bac3c750c7e1b21206fdaa60346c456 (diff)
downloadrust-674cd6125da1277af2d864b7d4e637c0a73f142c.tar.gz
rust-674cd6125da1277af2d864b7d4e637c0a73f142c.zip
Clairify Vec::capacity docs
Fixes #103326
-rw-r--r--library/alloc/src/vec/mod.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 6a71f08330c..bbbdc3aa2a2 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -868,13 +868,14 @@ impl<T, A: Allocator> Vec<T, A> {
         (ptr, len, capacity, alloc)
     }
 
-    /// Returns the number of elements the vector can hold without
+    /// Returns the total number of elements the vector can hold without
     /// reallocating.
     ///
     /// # Examples
     ///
     /// ```
-    /// let vec: Vec<i32> = Vec::with_capacity(10);
+    /// let mut vec: Vec<i32> = Vec::with_capacity(10);
+    /// vec.push(42);
     /// assert_eq!(vec.capacity(), 10);
     /// ```
     #[inline]