From 12b4cf8c6c79239cd7c3c2e7dbb2ea97351da02e Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 29 Aug 2020 18:38:18 +0800 Subject: [PATCH] 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 b4ad238680f7..c2b835bcf338 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: