Improved examples on Vec documentation

- shrink_to_fit example is now more clear by asserting the capacity value
This commit is contained in:
areski 2014-10-23 16:45:36 +02:00
parent 8a40854660
commit fe6847a25b

@ -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> {