From 4867a2122599ef376280622ad9dfa9d8e730041f Mon Sep 17 00:00:00 2001 From: Yoh Deadfall Date: Mon, 5 Jul 2021 14:30:15 +0300 Subject: [PATCH 1/2] Stabilize Vec::shrink_to --- library/alloc/src/collections/binary_heap.rs | 3 +-- library/alloc/src/collections/vec_deque/mod.rs | 3 +-- library/alloc/src/string.rs | 3 +-- library/alloc/src/vec/mod.rs | 3 +-- library/std/src/collections/hash/map.rs | 3 +-- library/std/src/collections/hash/set.rs | 3 +-- library/std/src/ffi/os_str.rs | 3 +-- library/std/src/lib.rs | 1 - library/std/src/path.rs | 2 +- 9 files changed, 8 insertions(+), 16 deletions(-) diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 2f656e4a6b4ac..956e34550938d 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -965,7 +965,6 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// use std::collections::BinaryHeap; /// let mut heap: BinaryHeap = BinaryHeap::with_capacity(100); /// @@ -974,7 +973,7 @@ impl BinaryHeap { /// assert!(heap.capacity() >= 10); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.data.shrink_to(min_capacity) } diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 461e701be054e..a540a3b40a6c5 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -766,7 +766,6 @@ impl VecDeque { /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::with_capacity(15); @@ -777,7 +776,7 @@ impl VecDeque { /// buf.shrink_to(0); /// assert!(buf.capacity() >= 4); /// ``` - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { let min_capacity = cmp::min(min_capacity, self.capacity()); // We don't have to worry about an overflow as neither `self.len()` nor `self.capacity()` diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 0d8678291bef7..f3f589a433ad7 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -1098,7 +1098,6 @@ impl String { /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// let mut s = String::from("foo"); /// /// s.reserve(100); @@ -1111,7 +1110,7 @@ impl String { /// ``` #[cfg(not(no_global_oom_handling))] #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.vec.shrink_to(min_capacity) } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 61599259735c7..0e16a46fa2c61 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -942,7 +942,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// let mut vec = Vec::with_capacity(10); /// vec.extend([1, 2, 3]); /// assert_eq!(vec.capacity(), 10); @@ -952,7 +951,7 @@ impl Vec { /// assert!(vec.capacity() >= 3); /// ``` #[cfg(not(no_global_oom_handling))] - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { if self.capacity() > min_capacity { self.buf.shrink_to_fit(cmp::max(self.len, min_capacity)); diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index d7cb8a556367c..bc1a4862c7a97 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -665,7 +665,6 @@ where /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// use std::collections::HashMap; /// /// let mut map: HashMap = HashMap::with_capacity(100); @@ -678,7 +677,7 @@ where /// assert!(map.capacity() >= 2); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { 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 272e1c2be2b40..d65a7e90dcf3d 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -466,7 +466,6 @@ where /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// use std::collections::HashSet; /// /// let mut set = HashSet::with_capacity(100); @@ -479,7 +478,7 @@ where /// assert!(set.capacity() >= 2); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.base.shrink_to(min_capacity) } diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 2a85f375ae279..00fe055198d12 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -319,7 +319,6 @@ impl OsString { /// # Examples /// /// ``` - /// #![feature(shrink_to)] /// use std::ffi::OsString; /// /// let mut s = OsString::from("foo"); @@ -333,7 +332,7 @@ impl OsString { /// assert!(s.capacity() >= 3); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 6f389f000af93..d21164752da0f 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -306,7 +306,6 @@ #![feature(ready_macro)] #![feature(rustc_attrs)] #![feature(rustc_private)] -#![feature(shrink_to)] #![feature(slice_concat_ext)] #![feature(slice_internals)] #![feature(slice_ptr_get)] diff --git a/library/std/src/path.rs b/library/std/src/path.rs index c71751efb9f9a..7d554c47702b9 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1398,7 +1398,7 @@ impl PathBuf { /// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. /// /// [`shrink_to`]: OsString::shrink_to - #[unstable(feature = "shrink_to", issue = "56431")] + #[stable(feature = "shrink_to", since = "1.55.0")] #[inline] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) From 8ec5060cdd16c772fa9474540ccda3f95996a653 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 8 Aug 2021 11:36:53 -0700 Subject: [PATCH 2/2] Bump shrink_to stabilization to Rust 1.56 --- library/alloc/src/collections/binary_heap.rs | 2 +- library/alloc/src/collections/vec_deque/mod.rs | 2 +- library/alloc/src/string.rs | 2 +- library/alloc/src/vec/mod.rs | 2 +- library/std/src/collections/hash/map.rs | 2 +- library/std/src/collections/hash/set.rs | 2 +- library/std/src/ffi/os_str.rs | 2 +- library/std/src/path.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 956e34550938d..23c2c82f29d19 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -973,7 +973,7 @@ impl BinaryHeap { /// assert!(heap.capacity() >= 10); /// ``` #[inline] - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.data.shrink_to(min_capacity) } diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index a540a3b40a6c5..3bfbe66d2b0ed 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -776,7 +776,7 @@ impl VecDeque { /// buf.shrink_to(0); /// assert!(buf.capacity() >= 4); /// ``` - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { let min_capacity = cmp::min(min_capacity, self.capacity()); // We don't have to worry about an overflow as neither `self.len()` nor `self.capacity()` diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index f3f589a433ad7..1b7edf65c8286 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -1110,7 +1110,7 @@ impl String { /// ``` #[cfg(not(no_global_oom_handling))] #[inline] - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.vec.shrink_to(min_capacity) } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 0e16a46fa2c61..a660dc87cd42e 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -951,7 +951,7 @@ impl Vec { /// assert!(vec.capacity() >= 3); /// ``` #[cfg(not(no_global_oom_handling))] - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { if self.capacity() > min_capacity { self.buf.shrink_to_fit(cmp::max(self.len, min_capacity)); diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index bc1a4862c7a97..4995646f91efb 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -677,7 +677,7 @@ where /// assert!(map.capacity() >= 2); /// ``` #[inline] - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { 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 d65a7e90dcf3d..99ae639f3eec7 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -478,7 +478,7 @@ where /// assert!(set.capacity() >= 2); /// ``` #[inline] - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.base.shrink_to(min_capacity) } diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 00fe055198d12..46a1ff3f49eef 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -332,7 +332,7 @@ impl OsString { /// assert!(s.capacity() >= 3); /// ``` #[inline] - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 7d554c47702b9..69419145b1b4f 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1398,7 +1398,7 @@ impl PathBuf { /// Invokes [`shrink_to`] on the underlying instance of [`OsString`]. /// /// [`shrink_to`]: OsString::shrink_to - #[stable(feature = "shrink_to", since = "1.55.0")] + #[stable(feature = "shrink_to", since = "1.56.0")] #[inline] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity)