@@ -653,11 +653,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
653653 /// assert_eq!(map.first_key_value(), Some((&1, &"b")));
654654 /// ```
655655 #[ 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 ) > {
661657 let front = self . root . as_ref ( ) ?. as_ref ( ) . first_leaf_edge ( ) ;
662658 front. right_kv ( ) . ok ( ) . map ( Handle :: into_kv)
663659 }
@@ -682,21 +678,14 @@ impl<K: Ord, V> BTreeMap<K, V> {
682678 /// }
683679 /// ```
684680 #[ 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 > > {
690682 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+ } )
700689 }
701690
702691 /// Returns the last key-value pair in the map.
@@ -716,11 +705,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
716705 /// assert_eq!(map.last_key_value(), Some((&2, &"a")));
717706 /// ```
718707 #[ 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 ) > {
724709 let back = self . root . as_ref ( ) ?. as_ref ( ) . last_leaf_edge ( ) ;
725710 back. left_kv ( ) . ok ( ) . map ( Handle :: into_kv)
726711 }
@@ -745,21 +730,14 @@ impl<K: Ord, V> BTreeMap<K, V> {
745730 /// }
746731 /// ```
747732 #[ 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 > > {
753734 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+ } )
763741 }
764742
765743 /// Returns `true` if the map contains a value for the specified key.
0 commit comments