@@ -653,11 +653,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
653
653
/// assert_eq!(map.first_key_value(), Some((&1, &"b")));
654
654
/// ```
655
655
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
656
- pub fn first_key_value < T : ?Sized > ( & self ) -> Option < ( & K , & V ) >
657
- where
658
- T : Ord ,
659
- K : Borrow < T > ,
660
- {
656
+ pub fn first_key_value ( & self ) -> Option < ( & K , & V ) > {
661
657
let front = self . root . as_ref ( ) ?. as_ref ( ) . first_leaf_edge ( ) ;
662
658
front. right_kv ( ) . ok ( ) . map ( Handle :: into_kv)
663
659
}
@@ -682,21 +678,14 @@ impl<K: Ord, V> BTreeMap<K, V> {
682
678
/// }
683
679
/// ```
684
680
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
685
- pub fn first_entry < T : ?Sized > ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > >
686
- where
687
- T : Ord ,
688
- K : Borrow < T > ,
689
- {
681
+ pub fn first_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > > {
690
682
let front = self . root . as_mut ( ) ?. as_mut ( ) . first_leaf_edge ( ) ;
691
- if let Ok ( kv) = front. right_kv ( ) {
692
- Some ( OccupiedEntry {
693
- handle : kv. forget_node_type ( ) ,
694
- length : & mut self . length ,
695
- _marker : PhantomData ,
696
- } )
697
- } else {
698
- None
699
- }
683
+ let kv = front. right_kv ( ) . ok ( ) ?;
684
+ Some ( OccupiedEntry {
685
+ handle : kv. forget_node_type ( ) ,
686
+ length : & mut self . length ,
687
+ _marker : PhantomData ,
688
+ } )
700
689
}
701
690
702
691
/// Returns the last key-value pair in the map.
@@ -716,11 +705,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
716
705
/// assert_eq!(map.last_key_value(), Some((&2, &"a")));
717
706
/// ```
718
707
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
719
- pub fn last_key_value < T : ?Sized > ( & self ) -> Option < ( & K , & V ) >
720
- where
721
- T : Ord ,
722
- K : Borrow < T > ,
723
- {
708
+ pub fn last_key_value ( & self ) -> Option < ( & K , & V ) > {
724
709
let back = self . root . as_ref ( ) ?. as_ref ( ) . last_leaf_edge ( ) ;
725
710
back. left_kv ( ) . ok ( ) . map ( Handle :: into_kv)
726
711
}
@@ -745,21 +730,14 @@ impl<K: Ord, V> BTreeMap<K, V> {
745
730
/// }
746
731
/// ```
747
732
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
748
- pub fn last_entry < T : ?Sized > ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > >
749
- where
750
- T : Ord ,
751
- K : Borrow < T > ,
752
- {
733
+ pub fn last_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > > {
753
734
let back = self . root . as_mut ( ) ?. as_mut ( ) . last_leaf_edge ( ) ;
754
- if let Ok ( kv) = back. left_kv ( ) {
755
- Some ( OccupiedEntry {
756
- handle : kv. forget_node_type ( ) ,
757
- length : & mut self . length ,
758
- _marker : PhantomData ,
759
- } )
760
- } else {
761
- None
762
- }
735
+ let kv = back. left_kv ( ) . ok ( ) ?;
736
+ Some ( OccupiedEntry {
737
+ handle : kv. forget_node_type ( ) ,
738
+ length : & mut self . length ,
739
+ _marker : PhantomData ,
740
+ } )
763
741
}
764
742
765
743
/// Returns `true` if the map contains a value for the specified key.
0 commit comments