Auto merge of #29445 - igpay:patch-1, r=alexcrichton
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.
This commit is contained in:
commit
a18e0b2707
@ -429,7 +429,7 @@ impl<T> Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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<T> Vec<T> {
|
||||
/// # 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]);
|
||||
/// ```
|
||||
|
Loading…
x
Reference in New Issue
Block a user