From 4be5783748b1c84ca11a22c2a9a0d1cdab10a8e7 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 11 Feb 2017 20:29:29 +1100 Subject: [PATCH] Add notes about capacity effects to Vec::truncate() --- src/libcollections/string.rs | 3 +++ src/libcollections/vec.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 4c82e2e2e7e..6f1c13e31b1 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -999,6 +999,9 @@ impl String { /// If `new_len` is greater than the string's current length, this has no /// effect. /// + /// Note that this method has no effect on the allocated capacity + /// of the string + /// /// # Panics /// /// Panics if `new_len` does not lie on a [`char`] boundary. diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index dc0f33d9bc3..0530df68633 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -545,6 +545,9 @@ impl Vec { /// The [`drain`] method can emulate `truncate`, but causes the excess /// elements to be returned instead of dropped. /// + /// Note that this method has no effect on the allocated capacity + /// of the vector. + /// /// # Examples /// /// Truncating a five element vector to two elements: @@ -1089,6 +1092,9 @@ impl Vec { /// Clears the vector, removing all values. /// + /// Note that this method has no effect on the allocated capacity + /// of the vector. + /// /// # Examples /// /// ```