diff options
| author | Thom Wiggers <thom@thomwiggers.nl> | 2021-01-24 13:29:39 +0100 |
|---|---|---|
| committer | Thom Wiggers <thom@thomwiggers.nl> | 2021-01-26 19:25:37 +0100 |
| commit | d069c58e78891d453b0b17adfecd368694fd289f (patch) | |
| tree | 097bcb7a715f4b3e38faf9a1e004405bb92669fd /library/std/src | |
| parent | 85e355ea9bd86ac6580a5d422a65dbf689845808 (diff) | |
| download | rust-d069c58e78891d453b0b17adfecd368694fd289f.tar.gz rust-d069c58e78891d453b0b17adfecd368694fd289f.zip | |
shrink_to shouldn't panic on len greater than capacity
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/collections/hash/map.rs | 4 | ||||
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 4 | ||||
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 3 |
3 files changed, 3 insertions, 8 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 829fc3817af..28a25572dd8 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -658,8 +658,7 @@ where /// down no lower than the supplied limit while maintaining the internal rules /// and possibly leaving some space in accordance with the resize policy. /// - /// Panics if the current capacity is smaller than the supplied - /// minimum capacity. + /// If the current capacity is less than the lower limit, this is a no-op. /// /// # Examples /// @@ -679,7 +678,6 @@ where #[inline] #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] pub fn shrink_to(&mut self, min_capacity: usize) { - assert!(self.capacity() >= min_capacity, "Tried to shrink to a larger capacity"); self.base.shrink_to(min_capacity); } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index baa3026ff75..b08510d6b01 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -462,9 +462,7 @@ where /// down no lower than the supplied limit while maintaining the internal rules /// and possibly leaving some space in accordance with the resize policy. /// - /// Panics if the current capacity is smaller than the supplied - /// minimum capacity. - /// + /// If the current capacity is less than the lower limit, this is a no-op. /// # Examples /// /// ``` diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 32f0f8a52f8..21060182d60 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -304,8 +304,7 @@ impl OsString { /// The capacity will remain at least as large as both the length /// and the supplied value. /// - /// Panics if the current capacity is smaller than the supplied - /// minimum capacity. + /// If the current capacity is less than the lower limit, this is a no-op. /// /// # Examples /// |
