Skip to content

Commit a18e0b2

Browse files
committed
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.
2 parents 01fd4d6 + 39289d0 commit a18e0b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libcollections/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,15 @@ impl<T> Vec<T> {
429429
}
430430
}
431431

432-
/// Shorten a vector, dropping excess elements.
432+
/// Shorten a vector to be `len` elements long, dropping excess elements.
433433
///
434434
/// If `len` is greater than the vector's current length, this has no
435435
/// effect.
436436
///
437437
/// # Examples
438438
///
439439
/// ```
440-
/// let mut vec = vec![1, 2, 3, 4];
440+
/// let mut vec = vec![1, 2, 3, 4, 5];
441441
/// vec.truncate(2);
442442
/// assert_eq!(vec, [1, 2]);
443443
/// ```

0 commit comments

Comments
 (0)