You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4366,9 +4384,9 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
4366
4384
/// assert_eq!(map["poneyland"], 37);
4367
4385
/// ```
4368
4386
#[cfg_attr(feature = "inline-more", inline)]
4369
-
pubfninsert(self,value:V) -> &'amutV
4387
+
pubfninsert(self,value:V) -> &'mapmutV
4370
4388
where
4371
-
K:Hash + From<&'bQ>,
4389
+
K:Hash + From<&'keyQ>,
4372
4390
S:BuildHasher,
4373
4391
{
4374
4392
let table = &mutself.table.table;
@@ -4380,6 +4398,24 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
4380
4398
&mut entry.1
4381
4399
}
4382
4400
4401
+
/// provide explicit key at insert-time instead of relying on there being effectively a from &K to K implementation and not working with cloneable values
4402
+
#[cfg_attr(feature = "inline-more", inline)]
4403
+
pubfninsert_kv(self,key:K,value:V) -> &'mapmutV
4404
+
where
4405
+
K:Hash,
4406
+
for<'k>&'kK:PartialEq<&'keyQ>,
4407
+
S:BuildHasher,
4408
+
{
4409
+
let table = &mutself.table.table;
4410
+
assert!(&key == self.key);
4411
+
let entry = table.insert_entry(
4412
+
self.hash,
4413
+
(key, value),
4414
+
make_hasher::<_,V,S>(&self.table.hash_builder),
4415
+
);
4416
+
&mut entry.1
4417
+
}
4418
+
4383
4419
/// Sets the value of the entry with the [`VacantEntryRef`]'s key,
4384
4420
/// and returns an [`OccupiedEntry`].
4385
4421
///
@@ -4397,9 +4433,9 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
0 commit comments