Skip to content

Commit 7d01f51

Browse files
committed
Auto merge of #389 - TheBlueMatt:master, r=Amanieu
Provide default hasher types to `Vacant` and `Occupied` entries For code which may select to use the `std` `HashMap` or the `hashbrown` `HashMap` based on feature or cfg flags, being forced to provide an explicit hash argument to `VacantEntry` or `OccupiedEntry` structs requires jumping through some hoops. Specifically, the `std` `hash_map::*Entry` structs don't take a hasher type argument at all, making the downstream code change the type entirely when switching from `std` to `hashbrown` or back. For simplicity, its nice to have the argument be optional on the `hashbrown` end, which would let the same code compile with either map.
2 parents a1cdff0 + c6affc5 commit 7d01f51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,7 +4297,7 @@ impl<K: Debug, V: Debug, S, A: Allocator + Clone> Debug for Entry<'_, K, V, S, A
42974297
/// assert_eq!(map.get(&"c"), None);
42984298
/// assert_eq!(map.len(), 2);
42994299
/// ```
4300-
pub struct OccupiedEntry<'a, K, V, S, A: Allocator + Clone = Global> {
4300+
pub struct OccupiedEntry<'a, K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
43014301
hash: u64,
43024302
key: Option<K>,
43034303
elem: Bucket<(K, V)>,
@@ -4360,7 +4360,7 @@ impl<K: Debug, V: Debug, S, A: Allocator + Clone> Debug for OccupiedEntry<'_, K,
43604360
/// }
43614361
/// assert!(map[&"b"] == 20 && map.len() == 2);
43624362
/// ```
4363-
pub struct VacantEntry<'a, K, V, S, A: Allocator + Clone = Global> {
4363+
pub struct VacantEntry<'a, K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
43644364
hash: u64,
43654365
key: K,
43664366
table: &'a mut HashMap<K, V, S, A>,

0 commit comments

Comments
 (0)