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
@@ -4364,9 +4382,9 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
4364
4382
/// assert_eq!(map["poneyland"], 37);
4365
4383
/// ```
4366
4384
#[cfg_attr(feature = "inline-more", inline)]
4367
-
pubfninsert(self,value:V) -> &'amutV
4385
+
pubfninsert(self,value:V) -> &'mapmutV
4368
4386
where
4369
-
K:Hash + From<&'bQ>,
4387
+
K:Hash + From<&'keyQ>,
4370
4388
S:BuildHasher,
4371
4389
{
4372
4390
let table = &mutself.table.table;
@@ -4378,6 +4396,24 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
4378
4396
&mut entry.1
4379
4397
}
4380
4398
4399
+
/// 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
4400
+
#[cfg_attr(feature = "inline-more", inline)]
4401
+
pubfninsert_kv(self,key:K,value:V) -> &'mapmutV
4402
+
where
4403
+
K:Hash,
4404
+
for<'k>&'kK:PartialEq<&'keyQ>,
4405
+
S:BuildHasher,
4406
+
{
4407
+
let table = &mutself.table.table;
4408
+
assert!(&key == self.key);
4409
+
let entry = table.insert_entry(
4410
+
self.hash,
4411
+
(key, value),
4412
+
make_hasher::<_,V,S>(&self.table.hash_builder),
4413
+
);
4414
+
&mut entry.1
4415
+
}
4416
+
4381
4417
/// Sets the value of the entry with the [`VacantEntryRef`]'s key,
4382
4418
/// and returns an [`OccupiedEntry`].
4383
4419
///
@@ -4395,9 +4431,9 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
0 commit comments