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
Auto merge of #340 - JustForFun88:add_new_extend, r=Amanieu
Adding `Extend<&'a (K, V)> for HashMap<K, V, S, A>`
I think that it is strange that we can do something like this:
```rust
fn main() {
use hashbrown::HashMap;
let mut map = HashMap::new();
let some_vec: Vec<_> = vec![(1, 1), (2, 2), (3, 3), (4, 4)];
map.extend(some_vec.iter().map(|&(k, v)| (k, v)));
}
```
but cannot do something like this:
```rust
fn main() {
use hashbrown::HashMap;
let mut map = HashMap::new();
let some_vec: Vec<_> = vec![(1, 1), (2, 2), (3, 3), (4, 4)];
map.extend(some_vec.iter()); // Or map.extend(&some_vec);
}
```
In any case, it can work only if K and V are Copy, and also inside `Extend<(K, V)>` we use `HashMap::insert`, not `HashMap::insert_unique_unchecked`, so adding `Extend<&'a (K, V)>` should be Ok.
0 commit comments