-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters