Skip to content

Commit 60a0edc

Browse files
committed
Auto merge of #39738 - keeperofdakeys:vec-docs, r=GuillaumeGomez
Add notes about capacity effects to Vec::truncate() Add notes about the effects of Vec::truncate() and Vec::clear() on the capacity of a vector.
2 parents 44e9e0a + 4be5783 commit 60a0edc

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
@@ -548,6 +548,9 @@ impl<T> Vec<T> {
548548
/// The [`drain`] method can emulate `truncate`, but causes the excess
549549
/// elements to be returned instead of dropped.
550550
///
551+
/// Note that this method has no effect on the allocated capacity
552+
/// of the vector.
553+
///
551554
/// # Examples
552555
///
553556
/// Truncating a five element vector to two elements:
@@ -1092,6 +1095,9 @@ impl<T> Vec<T> {
10921095

10931096
/// Clears the vector, removing all values.
10941097
///
1098+
/// Note that this method has no effect on the allocated capacity
1099+
/// of the vector.
1100+
///
10951101
/// # Examples
10961102
///
10971103
/// ```

0 commit comments

Comments
 (0)