]> git.lizzy.rs Git - rust.git/commitdiff
Add @thestinger comment explaining that shrink_to_fit might drop down as close as...
authorareski <areski@gmail.com>
Mon, 27 Oct 2014 21:32:53 +0000 (22:32 +0100)
committerareski <areski@gmail.com>
Mon, 27 Oct 2014 21:32:53 +0000 (22:32 +0100)
src/libcollections/vec.rs

index f43d03fb11fdfe51ee6c8b8a79b9315355ba21e1..a9171afe25d69465401cd66c7175103ed26c4cf9 100644 (file)
@@ -636,7 +636,9 @@ pub fn reserve_exact(&mut self, capacity: uint) {
         }
     }
 
-    /// Shrinks the capacity of the vector as much as possible.
+    /// Shrinks the capacity of the vector as much as possible. It will drop
+    /// down as close as possible to the length but the allocator may still
+    /// inform the vector that there is space for a few more elements.
     ///
     /// # Example
     ///
@@ -645,7 +647,7 @@ pub fn reserve_exact(&mut self, capacity: uint) {
     /// vec.push_all([1, 2, 3]);
     /// assert_eq!(vec.capacity(), 10);
     /// vec.shrink_to_fit();
-    /// assert_eq!(vec.capacity(), 3);
+    /// assert!(vec.capacity() >= 3);
     /// ```
     #[stable]
     pub fn shrink_to_fit(&mut self) {