From 596b0c88cc1f496c3a50a5eb0250aed443495609 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 3 Jun 2020 01:29:02 +0800 Subject: [PATCH] Add assert to Vec with_capacity docs --- src/liballoc/vec.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 42fb1f8c737b3..22d43468771b4 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -348,9 +348,11 @@ impl Vec { /// for i in 0..10 { /// vec.push(i); /// } + /// assert_eq!(vec.capacity(), 10); /// /// // ...but this may make the vector reallocate /// vec.push(11); + /// assert!(vec.capacity() >= 11); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")]