Skip to content

Commit 4667b94

Browse files
authored
Rollup merge of #101727 - est31:stabilize_map_first_last, r=m-ou-se
Stabilize map_first_last Stabilizes the following functions: ```Rust impl<T> BTreeSet<T> { pub fn first(&self) -> Option<&T> where T: Ord; pub fn last(&self) -> Option<&T> where T: Ord; pub fn pop_first(&mut self) -> Option<T> where T: Ord; pub fn pop_last(&mut self) -> Option<T> where T: Ord; } impl<K, V> BTreeMap<K, V> { pub fn first_key_value(&self) -> Option<(&K, &V)> where K: Ord; pub fn last_key_value(&self) -> Option<(&K, &V)> where K: Ord; pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord; pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord; pub fn pop_first(&mut self) -> Option<(K, V)> where K: Ord; pub fn pop_last(&mut self) -> Option<(K, V)> where K: Ord; } ``` Closes #62924 ~~Blocked on the [FCP](rust-lang/rust#62924 (comment)) finishing.~~ Edit: It finished!
2 parents 87d87b3 + a121a37 commit 4667b94

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

alloc/benches/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![cfg(not(target_os = "android"))]
44
#![feature(btree_drain_filter)]
55
#![feature(iter_next_chunk)]
6-
#![feature(map_first_last)]
76
#![feature(repr_simd)]
87
#![feature(slice_partition_dedup)]
98
#![feature(test)]

alloc/src/collections/btree/map.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
703703
/// Basic usage:
704704
///
705705
/// ```
706-
/// #![feature(map_first_last)]
707706
/// use std::collections::BTreeMap;
708707
///
709708
/// let mut map = BTreeMap::new();
@@ -712,7 +711,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
712711
/// map.insert(2, "a");
713712
/// assert_eq!(map.first_key_value(), Some((&1, &"b")));
714713
/// ```
715-
#[unstable(feature = "map_first_last", issue = "62924")]
714+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
716715
pub fn first_key_value(&self) -> Option<(&K, &V)>
717716
where
718717
K: Ord,
@@ -727,7 +726,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
727726
/// # Examples
728727
///
729728
/// ```
730-
/// #![feature(map_first_last)]
731729
/// use std::collections::BTreeMap;
732730
///
733731
/// let mut map = BTreeMap::new();
@@ -741,7 +739,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
741739
/// assert_eq!(*map.get(&1).unwrap(), "first");
742740
/// assert_eq!(*map.get(&2).unwrap(), "b");
743741
/// ```
744-
#[unstable(feature = "map_first_last", issue = "62924")]
742+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
745743
pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V, A>>
746744
where
747745
K: Ord,
@@ -765,7 +763,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
765763
/// Draining elements in ascending order, while keeping a usable map each iteration.
766764
///
767765
/// ```
768-
/// #![feature(map_first_last)]
769766
/// use std::collections::BTreeMap;
770767
///
771768
/// let mut map = BTreeMap::new();
@@ -776,7 +773,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
776773
/// }
777774
/// assert!(map.is_empty());
778775
/// ```
779-
#[unstable(feature = "map_first_last", issue = "62924")]
776+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
780777
pub fn pop_first(&mut self) -> Option<(K, V)>
781778
where
782779
K: Ord,
@@ -792,15 +789,14 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
792789
/// Basic usage:
793790
///
794791
/// ```
795-
/// #![feature(map_first_last)]
796792
/// use std::collections::BTreeMap;
797793
///
798794
/// let mut map = BTreeMap::new();
799795
/// map.insert(1, "b");
800796
/// map.insert(2, "a");
801797
/// assert_eq!(map.last_key_value(), Some((&2, &"a")));
802798
/// ```
803-
#[unstable(feature = "map_first_last", issue = "62924")]
799+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
804800
pub fn last_key_value(&self) -> Option<(&K, &V)>
805801
where
806802
K: Ord,
@@ -815,7 +811,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
815811
/// # Examples
816812
///
817813
/// ```
818-
/// #![feature(map_first_last)]
819814
/// use std::collections::BTreeMap;
820815
///
821816
/// let mut map = BTreeMap::new();
@@ -829,7 +824,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
829824
/// assert_eq!(*map.get(&1).unwrap(), "a");
830825
/// assert_eq!(*map.get(&2).unwrap(), "last");
831826
/// ```
832-
#[unstable(feature = "map_first_last", issue = "62924")]
827+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
833828
pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V, A>>
834829
where
835830
K: Ord,
@@ -853,7 +848,6 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
853848
/// Draining elements in descending order, while keeping a usable map each iteration.
854849
///
855850
/// ```
856-
/// #![feature(map_first_last)]
857851
/// use std::collections::BTreeMap;
858852
///
859853
/// let mut map = BTreeMap::new();
@@ -864,7 +858,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
864858
/// }
865859
/// assert!(map.is_empty());
866860
/// ```
867-
#[unstable(feature = "map_first_last", issue = "62924")]
861+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
868862
pub fn pop_last(&mut self) -> Option<(K, V)>
869863
where
870864
K: Ord,

alloc/src/collections/btree/set.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,6 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
786786
/// Basic usage:
787787
///
788788
/// ```
789-
/// #![feature(map_first_last)]
790789
/// use std::collections::BTreeSet;
791790
///
792791
/// let mut set = BTreeSet::new();
@@ -797,7 +796,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
797796
/// assert_eq!(set.first(), Some(&1));
798797
/// ```
799798
#[must_use]
800-
#[unstable(feature = "map_first_last", issue = "62924")]
799+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
801800
pub fn first(&self) -> Option<&T>
802801
where
803802
T: Ord,
@@ -813,7 +812,6 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
813812
/// Basic usage:
814813
///
815814
/// ```
816-
/// #![feature(map_first_last)]
817815
/// use std::collections::BTreeSet;
818816
///
819817
/// let mut set = BTreeSet::new();
@@ -824,7 +822,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
824822
/// assert_eq!(set.last(), Some(&2));
825823
/// ```
826824
#[must_use]
827-
#[unstable(feature = "map_first_last", issue = "62924")]
825+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
828826
pub fn last(&self) -> Option<&T>
829827
where
830828
T: Ord,
@@ -838,7 +836,6 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
838836
/// # Examples
839837
///
840838
/// ```
841-
/// #![feature(map_first_last)]
842839
/// use std::collections::BTreeSet;
843840
///
844841
/// let mut set = BTreeSet::new();
@@ -849,7 +846,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
849846
/// }
850847
/// assert!(set.is_empty());
851848
/// ```
852-
#[unstable(feature = "map_first_last", issue = "62924")]
849+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
853850
pub fn pop_first(&mut self) -> Option<T>
854851
where
855852
T: Ord,
@@ -863,7 +860,6 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
863860
/// # Examples
864861
///
865862
/// ```
866-
/// #![feature(map_first_last)]
867863
/// use std::collections::BTreeSet;
868864
///
869865
/// let mut set = BTreeSet::new();
@@ -874,7 +870,7 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
874870
/// }
875871
/// assert!(set.is_empty());
876872
/// ```
877-
#[unstable(feature = "map_first_last", issue = "62924")]
873+
#[stable(feature = "map_first_last", since = "CURRENT_RUSTC_VERSION")]
878874
pub fn pop_last(&mut self) -> Option<T>
879875
where
880876
T: Ord,

0 commit comments

Comments
 (0)