diff options
| author | Ivan Tham <pickfire@riseup.net> | 2020-08-29 18:38:18 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-29 18:38:18 +0800 |
| commit | 12b4cf8c6c79239cd7c3c2e7dbb2ea97351da02e (patch) | |
| tree | 44a95ca23fa832c950b44725c746e055e18e85c2 | |
| parent | 1dc748fb3d2c54f536e6abd74f1ad34b3624f640 (diff) | |
| download | rust-12b4cf8c6c79239cd7c3c2e7dbb2ea97351da02e.tar.gz rust-12b4cf8c6c79239cd7c3c2e7dbb2ea97351da02e.zip | |
Use assertions on Vec doc
Clarify what the state of Vec after with_capacity on doc.
| -rw-r--r-- | library/alloc/src/vec.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f..c2b835bcf33 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -116,8 +116,10 @@ use crate::raw_vec::RawVec; /// assert_eq!(vec, [0, 0, 0, 0, 0]); /// /// // The following is equivalent, but potentially slower: -/// let mut vec1 = Vec::with_capacity(5); -/// vec1.resize(5, 0); +/// let mut vec = Vec::with_capacity(5); +/// assert_eq!(vec, []); +/// vec.resize(5, 0); +/// assert_eq!(vec, [0, 0, 0, 0, 0]); /// ``` /// /// Use a `Vec<T>` as an efficient stack: |
