Skip to content

Commit 12b4cf8

Browse files
authored
Use assertions on Vec doc
Clarify what the state of Vec after with_capacity on doc.
1 parent 1dc748f commit 12b4cf8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/alloc/src/vec.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ use crate::raw_vec::RawVec;
116116
/// assert_eq!(vec, [0, 0, 0, 0, 0]);
117117
///
118118
/// // The following is equivalent, but potentially slower:
119-
/// let mut vec1 = Vec::with_capacity(5);
120-
/// vec1.resize(5, 0);
119+
/// let mut vec = Vec::with_capacity(5);
120+
/// assert_eq!(vec, []);
121+
/// vec.resize(5, 0);
122+
/// assert_eq!(vec, [0, 0, 0, 0, 0]);
121123
/// ```
122124
///
123125
/// Use a `Vec<T>` as an efficient stack:

0 commit comments

Comments
 (0)