File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -636,13 +636,18 @@ impl<T> Vec<T> {
636
636
}
637
637
}
638
638
639
- /// Shrinks the capacity of the vector as much as possible.
639
+ /// Shrinks the capacity of the vector as much as possible. It will drop
640
+ /// down as close as possible to the length but the allocator may still
641
+ /// inform the vector that there is space for a few more elements.
640
642
///
641
643
/// # Example
642
644
///
643
645
/// ```
644
- /// let mut vec = vec![1i, 2, 3];
646
+ /// let mut vec: Vec<int> = Vec::with_capacity(10);
647
+ /// vec.push_all([1, 2, 3]);
648
+ /// assert_eq!(vec.capacity(), 10);
645
649
/// vec.shrink_to_fit();
650
+ /// assert!(vec.capacity() >= 3);
646
651
/// ```
647
652
#[ stable]
648
653
pub fn shrink_to_fit ( & mut self ) {
@@ -830,6 +835,7 @@ impl<T> Vec<T> {
830
835
/// for num in vec.iter_mut() {
831
836
/// *num = 0;
832
837
/// }
838
+ /// assert_eq!(vec, vec![0i, 0, 0]);
833
839
/// ```
834
840
#[ inline]
835
841
pub fn iter_mut < ' a > ( & ' a mut self ) -> MutItems < ' a , T > {
You can’t perform that action at this time.
0 commit comments