mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-07 20:58:39 +00:00
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.
This commit is contained in:
commit
60a0edc6c2
@ -999,6 +999,9 @@ impl String {
|
|||||||
/// If `new_len` is greater than the string's current length, this has no
|
/// If `new_len` is greater than the string's current length, this has no
|
||||||
/// effect.
|
/// effect.
|
||||||
///
|
///
|
||||||
|
/// Note that this method has no effect on the allocated capacity
|
||||||
|
/// of the string
|
||||||
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if `new_len` does not lie on a [`char`] boundary.
|
/// Panics if `new_len` does not lie on a [`char`] boundary.
|
||||||
|
@ -548,6 +548,9 @@ impl<T> Vec<T> {
|
|||||||
/// The [`drain`] method can emulate `truncate`, but causes the excess
|
/// The [`drain`] method can emulate `truncate`, but causes the excess
|
||||||
/// elements to be returned instead of dropped.
|
/// elements to be returned instead of dropped.
|
||||||
///
|
///
|
||||||
|
/// Note that this method has no effect on the allocated capacity
|
||||||
|
/// of the vector.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// Truncating a five element vector to two elements:
|
/// Truncating a five element vector to two elements:
|
||||||
@ -1092,6 +1095,9 @@ impl<T> Vec<T> {
|
|||||||
|
|
||||||
/// Clears the vector, removing all values.
|
/// Clears the vector, removing all values.
|
||||||
///
|
///
|
||||||
|
/// Note that this method has no effect on the allocated capacity
|
||||||
|
/// of the vector.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
Loading…
Reference in New Issue
Block a user