From 12b4cf8c6c79239cd7c3c2e7dbb2ea97351da02e Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 18:38:18 +0800 Subject: [PATCH 1/2] Use assertions on Vec doc Clarify what the state of Vec after with_capacity on doc. --- library/alloc/src/vec.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index b4ad238680f79..c2b835bcf3383 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` as an efficient stack: From 2d1ab838342c880892a5243bf338b7ead7472928 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 23:07:40 +0800 Subject: [PATCH 2/2] Remove empty vec assertion flow distrupt Co-authored-by: Joshua Nelson --- library/alloc/src/vec.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index c2b835bcf3383..277183c120d61 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -117,7 +117,6 @@ use crate::raw_vec::RawVec; /// /// // The following is equivalent, but potentially slower: /// let mut vec = Vec::with_capacity(5); -/// assert_eq!(vec, []); /// vec.resize(5, 0); /// assert_eq!(vec, [0, 0, 0, 0, 0]); /// ```