Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,18 @@ 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
///
/// ```
/// 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!(vec.capacity() >= 3);
/// ```
#[stable]
pub fn shrink_to_fit(&mut self) {
Expand Down Expand Up @@ -830,6 +835,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> {
Expand Down