Skip to content

Commit e72ced8

Browse files
change OccupiedEntryRef::replace_entry_with to give out key references rather than borrowed key references
1 parent ecda296 commit e72ced8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/map.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5928,8 +5928,7 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> EntryRef<'a, 'b, K, Q, V,
59285928
#[cfg_attr(feature = "inline-more", inline)]
59295929
pub fn and_replace_entry_with<F>(self, f: F) -> Self
59305930
where
5931-
F: FnOnce(&Q, V) -> Option<V>,
5932-
K: Borrow<Q>,
5931+
F: FnOnce(&K, V) -> Option<V>,
59335932
{
59345933
match self {
59355934
EntryRef::Occupied(entry) => entry.replace_entry_with(f),
@@ -6294,16 +6293,15 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> OccupiedEntryRef<'a, 'b,
62946293
#[cfg_attr(feature = "inline-more", inline)]
62956294
pub fn replace_entry_with<F>(self, f: F) -> EntryRef<'a, 'b, K, Q, V, S, A>
62966295
where
6297-
F: FnOnce(&Q, V) -> Option<V>,
6298-
K: Borrow<Q>,
6296+
F: FnOnce(&K, V) -> Option<V>,
62996297
{
63006298
unsafe {
63016299
let mut spare_key = None;
63026300

63036301
self.table
63046302
.table
63056303
.replace_bucket_with(self.elem.clone(), |(key, value)| {
6306-
if let Some(new_value) = f(key.borrow(), value) {
6304+
if let Some(new_value) = f(&key, value) {
63076305
Some((key, new_value))
63086306
} else {
63096307
spare_key = Some(KeyOrRef::Owned(key));

0 commit comments

Comments
 (0)