From a446b68380f1f223b03baebb71d591d42c98dbbd Mon Sep 17 00:00:00 2001 From: areski Date: Mon, 27 Oct 2014 22:32:53 +0100 Subject: [PATCH] Add @thestinger comment explaining that shrink_to_fit might drop down as close as possible but not to the minimun --- src/libcollections/vec.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index f43d03fb11f..a9171afe25d 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -636,7 +636,9 @@ impl Vec { } } - /// 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 @@ impl Vec { /// 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) {