about summary refs log tree commit diff
diff options
context:
space:
mode:
authorareski <areski@gmail.com>2014-10-23 16:45:36 +0200
committerareski <areski@gmail.com>2014-10-23 16:45:36 +0200
commitfe6847a25ba6ebad42fefde7e3a2e6aa0794b676 (patch)
tree318c82b4ad4178964a72b330460d1d0981aa34a1
parent8a4085466021c534427c544b860eabcdf4ed85df (diff)
downloadrust-fe6847a25ba6ebad42fefde7e3a2e6aa0794b676.tar.gz
rust-fe6847a25ba6ebad42fefde7e3a2e6aa0794b676.zip
Improved examples on Vec documentation
- shrink_to_fit example is now more clear by asserting the capacity value
-rw-r--r--src/libcollections/vec.rs6
1 files changed, 5 insertions, 1 deletions
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> {