]> git.lizzy.rs Git - rust.git/commitdiff
Add assert to Vec with_capacity docs
authorIvan Tham <pickfire@riseup.net>
Tue, 2 Jun 2020 17:29:02 +0000 (01:29 +0800)
committerIvan Tham <pickfire@riseup.net>
Tue, 2 Jun 2020 17:29:02 +0000 (01:29 +0800)
src/liballoc/vec.rs

index 42fb1f8c737b3fe92ba099e7dbd4169dd49e7176..22d43468771b45375c3a39b95df293ba964cae45 100644 (file)
@@ -348,9 +348,11 @@ pub const fn new() -> Vec<T> {
     /// 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")]