@@ -4562,7 +4562,7 @@ impl<K: Borrow<Q>, Q: ?Sized + Debug, V: Debug, S, A: Allocator + Clone> Debug
4562
4562
{
4563
4563
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
4564
4564
f. debug_struct ( "OccupiedEntryRef" )
4565
- . field ( "key" , & self . key ( ) )
4565
+ . field ( "key" , & self . key ( ) . borrow ( ) )
4566
4566
. field ( "value" , & self . get ( ) )
4567
4567
. finish ( )
4568
4568
}
@@ -5832,7 +5832,7 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> EntryRef<'a, 'b, K, Q, V,
5832
5832
K : Borrow < Q > ,
5833
5833
{
5834
5834
match * self {
5835
- EntryRef :: Occupied ( ref entry) => entry. key ( ) ,
5835
+ EntryRef :: Occupied ( ref entry) => entry. key ( ) . borrow ( ) ,
5836
5836
EntryRef :: Vacant ( ref entry) => entry. key ( ) ,
5837
5837
}
5838
5838
}
@@ -5928,8 +5928,7 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> EntryRef<'a, 'b, K, Q, V,
5928
5928
#[ cfg_attr( feature = "inline-more" , inline) ]
5929
5929
pub fn and_replace_entry_with < F > ( self , f : F ) -> Self
5930
5930
where
5931
- F : FnOnce ( & Q , V ) -> Option < V > ,
5932
- K : Borrow < Q > ,
5931
+ F : FnOnce ( & K , V ) -> Option < V > ,
5933
5932
{
5934
5933
match self {
5935
5934
EntryRef :: Occupied ( entry) => entry. replace_entry_with ( f) ,
@@ -5988,11 +5987,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> OccupiedEntryRef<'a, 'b,
5988
5987
/// }
5989
5988
/// ```
5990
5989
#[ cfg_attr( feature = "inline-more" , inline) ]
5991
- pub fn key ( & self ) -> & Q
5992
- where
5993
- K : Borrow < Q > ,
5994
- {
5995
- unsafe { & self . elem . as_ref ( ) . 0 } . borrow ( )
5990
+ pub fn key ( & self ) -> & K {
5991
+ unsafe { & self . elem . as_ref ( ) . 0 }
5996
5992
}
5997
5993
5998
5994
/// Take the ownership of the key and value from the map.
@@ -6297,16 +6293,15 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> OccupiedEntryRef<'a, 'b,
6297
6293
#[ cfg_attr( feature = "inline-more" , inline) ]
6298
6294
pub fn replace_entry_with < F > ( self , f : F ) -> EntryRef < ' a , ' b , K , Q , V , S , A >
6299
6295
where
6300
- F : FnOnce ( & Q , V ) -> Option < V > ,
6301
- K : Borrow < Q > ,
6296
+ F : FnOnce ( & K , V ) -> Option < V > ,
6302
6297
{
6303
6298
unsafe {
6304
6299
let mut spare_key = None ;
6305
6300
6306
6301
self . table
6307
6302
. table
6308
6303
. replace_bucket_with ( self . elem . clone ( ) , |( key, value) | {
6309
- if let Some ( new_value) = f ( key. borrow ( ) , value) {
6304
+ if let Some ( new_value) = f ( & key, value) {
6310
6305
Some ( ( key, new_value) )
6311
6306
} else {
6312
6307
spare_key = Some ( KeyOrRef :: Owned ( key) ) ;
0 commit comments