Skip to content

Commit 4be5783

Browse files
Add notes about capacity effects to Vec::truncate()
1 parent 2425b22 commit 4be5783

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/libcollections/string.rs

+3
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,9 @@ impl String {
999999
/// If `new_len` is greater than the string's current length, this has no
10001000
/// effect.
10011001
///
1002+
/// Note that this method has no effect on the allocated capacity
1003+
/// of the string
1004+
///
10021005
/// # Panics
10031006
///
10041007
/// Panics if `new_len` does not lie on a [`char`] boundary.

src/libcollections/vec.rs

+6
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ impl<T> Vec<T> {
545545
/// The [`drain`] method can emulate `truncate`, but causes the excess
546546
/// elements to be returned instead of dropped.
547547
///
548+
/// Note that this method has no effect on the allocated capacity
549+
/// of the vector.
550+
///
548551
/// # Examples
549552
///
550553
/// Truncating a five element vector to two elements:
@@ -1089,6 +1092,9 @@ impl<T> Vec<T> {
10891092

10901093
/// Clears the vector, removing all values.
10911094
///
1095+
/// Note that this method has no effect on the allocated capacity
1096+
/// of the vector.
1097+
///
10921098
/// # Examples
10931099
///
10941100
/// ```

0 commit comments

Comments
 (0)