diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-10-25 14:43:15 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-25 14:43:15 +0530 |
| commit | 35b46de61b015a2edac01bdcbbbc190ffcc57a71 (patch) | |
| tree | c6fd8c53f327a1dade27ae93dd59a78353d22328 /library/alloc/src/vec | |
| parent | 75023d61a191a0edf38e13f82bc88cddb2eb5f95 (diff) | |
| parent | 674cd6125da1277af2d864b7d4e637c0a73f142c (diff) | |
| download | rust-35b46de61b015a2edac01bdcbbbc190ffcc57a71.tar.gz rust-35b46de61b015a2edac01bdcbbbc190ffcc57a71.zip | |
Rollup merge of #103482 - aDotInTheVoid:vec-cap-docs, r=thomcc
Clairify Vec::capacity docs Update both the text and example to be clear that the method gives *total*, (not *spare*) capacity Fixes #103326
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 5 |
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] |
