Skip to content

Commit 8abce3e

Browse files
authored
Merge pull request #611 from tomkris/master
Relax constraint in hash_map::EntryRef insertion methods K: From<&Q> to &Q: Into<K>
2 parents b5b0655 + f3e266e commit 8abce3e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/map.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -4131,7 +4131,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> EntryRef<'a, 'b, K, Q, V, S, A> {
41314131
#[cfg_attr(feature = "inline-more", inline)]
41324132
pub fn insert(self, value: V) -> OccupiedEntry<'a, K, V, S, A>
41334133
where
4134-
K: Hash + From<&'b Q>,
4134+
K: Hash,
4135+
&'b Q: Into<K>,
41354136
S: BuildHasher,
41364137
{
41374138
match self {
@@ -4164,7 +4165,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> EntryRef<'a, 'b, K, Q, V, S, A> {
41644165
#[cfg_attr(feature = "inline-more", inline)]
41654166
pub fn or_insert(self, default: V) -> &'a mut V
41664167
where
4167-
K: Hash + From<&'b Q>,
4168+
K: Hash,
4169+
&'b Q: Into<K>,
41684170
S: BuildHasher,
41694171
{
41704172
match self {
@@ -4194,7 +4196,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> EntryRef<'a, 'b, K, Q, V, S, A> {
41944196
#[cfg_attr(feature = "inline-more", inline)]
41954197
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V
41964198
where
4197-
K: Hash + From<&'b Q>,
4199+
K: Hash,
4200+
&'b Q: Into<K>,
41984201
S: BuildHasher,
41994202
{
42004203
match self {
@@ -4225,7 +4228,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> EntryRef<'a, 'b, K, Q, V, S, A> {
42254228
#[cfg_attr(feature = "inline-more", inline)]
42264229
pub fn or_insert_with_key<F: FnOnce(&Q) -> V>(self, default: F) -> &'a mut V
42274230
where
4228-
K: Hash + Borrow<Q> + From<&'b Q>,
4231+
K: Hash + Borrow<Q>,
4232+
&'b Q: Into<K>,
42294233
S: BuildHasher,
42304234
{
42314235
match self {
@@ -4320,7 +4324,8 @@ impl<'a, 'b, K, Q: ?Sized, V: Default, S, A: Allocator> EntryRef<'a, 'b, K, Q, V
43204324
#[cfg_attr(feature = "inline-more", inline)]
43214325
pub fn or_default(self) -> &'a mut V
43224326
where
4323-
K: Hash + From<&'b Q>,
4327+
K: Hash,
4328+
&'b Q: Into<K>,
43244329
S: BuildHasher,
43254330
{
43264331
match self {
@@ -4368,7 +4373,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
43684373
#[cfg_attr(feature = "inline-more", inline)]
43694374
pub fn insert(self, value: V) -> &'a mut V
43704375
where
4371-
K: Hash + From<&'b Q>,
4376+
K: Hash,
4377+
&'b Q: Into<K>,
43724378
S: BuildHasher,
43734379
{
43744380
let table = &mut self.table.table;
@@ -4399,7 +4405,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator> VacantEntryRef<'a, 'b, K, Q, V, S
43994405
#[cfg_attr(feature = "inline-more", inline)]
44004406
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>
44014407
where
4402-
K: Hash + From<&'b Q>,
4408+
K: Hash,
4409+
&'b Q: Into<K>,
44034410
S: BuildHasher,
44044411
{
44054412
let elem = self.table.table.insert(

0 commit comments

Comments
 (0)