Skip to content

Commit ecda296

Browse files
change OccupiedEntryRef::key to return the key type rather than the borrowed key type
Fixes: #421
1 parent e8c96d0 commit ecda296

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/map.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4562,7 +4562,7 @@ impl<K: Borrow<Q>, Q: ?Sized + Debug, V: Debug, S, A: Allocator + Clone> Debug
45624562
{
45634563
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45644564
f.debug_struct("OccupiedEntryRef")
4565-
.field("key", &self.key())
4565+
.field("key", &self.key().borrow())
45664566
.field("value", &self.get())
45674567
.finish()
45684568
}
@@ -5832,7 +5832,7 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> EntryRef<'a, 'b, K, Q, V,
58325832
K: Borrow<Q>,
58335833
{
58345834
match *self {
5835-
EntryRef::Occupied(ref entry) => entry.key(),
5835+
EntryRef::Occupied(ref entry) => entry.key().borrow(),
58365836
EntryRef::Vacant(ref entry) => entry.key(),
58375837
}
58385838
}
@@ -5988,11 +5988,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> OccupiedEntryRef<'a, 'b,
59885988
/// }
59895989
/// ```
59905990
#[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()
5991+
pub fn key(&self) -> &K {
5992+
unsafe { &self.elem.as_ref().0 }
59965993
}
59975994

59985995
/// Take the ownership of the key and value from the map.

0 commit comments

Comments
 (0)