From fe6847a25ba6ebad42fefde7e3a2e6aa0794b676 Mon Sep 17 00:00:00 2001
From: areski <areski@gmail.com>
Date: Thu, 23 Oct 2014 16:45:36 +0200
Subject: [PATCH 1/2] Improved examples on Vec documentation

- shrink_to_fit example is now more clear by asserting the capacity value
---
 src/libcollections/vec.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index e608a7d22dc..f43d03fb11f 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -641,8 +641,11 @@ impl<T> Vec<T> {
     /// # Example
     ///
     /// ```
-    /// let mut vec = vec![1i, 2, 3];
+    /// let mut vec: Vec<int> = Vec::with_capacity(10);
+    /// vec.push_all([1, 2, 3]);
+    /// assert_eq!(vec.capacity(), 10);
     /// vec.shrink_to_fit();
+    /// assert_eq!(vec.capacity(), 3);
     /// ```
     #[stable]
     pub fn shrink_to_fit(&mut self) {
@@ -830,6 +833,7 @@ impl<T> Vec<T> {
     /// for num in vec.iter_mut() {
     ///     *num = 0;
     /// }
+    /// assert_eq!(vec, vec![0i, 0, 0]);
     /// ```
     #[inline]
     pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a,T> {

From a446b68380f1f223b03baebb71d591d42c98dbbd Mon Sep 17 00:00:00 2001
From: areski <areski@gmail.com>
Date: Mon, 27 Oct 2014 22:32:53 +0100
Subject: [PATCH 2/2] 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<T> Vec<T> {
         }
     }
 
-    /// 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<T> Vec<T> {
     /// 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) {