From 39289d00fdfe6e845e3325ff8f388cc40e9620f3 Mon Sep 17 00:00:00 2001 From: Cameron Sun Date: Wed, 28 Oct 2015 21:38:46 -0400 Subject: [PATCH] Update docstring for truncate This documentation confused me when trying to use truncate on a project. Originally, it was unclear whether truncate removed the last `len` elements, or whether it cut down the vector to be exactly `len` elements long. The example was also ambiguous. --- src/libcollections/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 897fea5309c..adf3ec13cfd 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -429,7 +429,7 @@ impl Vec { } } - /// Shorten a vector, dropping excess elements. + /// Shorten a vector to be `len` elements long, dropping excess elements. /// /// If `len` is greater than the vector's current length, this has no /// effect. @@ -437,7 +437,7 @@ impl Vec { /// # Examples /// /// ``` - /// let mut vec = vec![1, 2, 3, 4]; + /// let mut vec = vec![1, 2, 3, 4, 5]; /// vec.truncate(2); /// assert_eq!(vec, [1, 2]); /// ```