diff --git a/CHANGELOG.md b/CHANGELOG.md index cff6b52..fb26684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `hashbrown::hash_set` macro +### Changed + +* Explicitly typed map macros: keys also cast now (before only values were + casted) + ### Removed * `map` macro diff --git a/src/_std.rs b/src/_std.rs index 47ced38..8e8990e 100644 --- a/src/_std.rs +++ b/src/_std.rs @@ -46,7 +46,7 @@ macro_rules! hash_map { #[macro_export] macro_rules! hash_map_e { {$($k: expr => $v: expr),* $(,)?} => { - ::std::collections::HashMap::from([$(($k, $v as _),)*]) + ::std::collections::HashMap::from([$(($k as _, $v as _),)*]) }; } @@ -96,7 +96,7 @@ macro_rules! btree_map { #[macro_export] macro_rules! btree_map_e { {$($k: expr => $v: expr),* $(,)?} => { - ::std::collections::BTreeMap::from([$(($k, $v as _),)*]) + ::std::collections::BTreeMap::from([$(($k as _, $v as _),)*]) }; } diff --git a/src/hashbrown.rs b/src/hashbrown.rs index a972bd4..2979a09 100644 --- a/src/hashbrown.rs +++ b/src/hashbrown.rs @@ -71,7 +71,7 @@ macro_rules! __hb_hash_map { #[macro_export] macro_rules! __hb_hash_map_e { {$($k: expr => $v: expr),* $(,)?} => { - <::hashbrown::HashMap::<_, _> as ::core::iter::FromIterator<_>>::from_iter([$(($k, $v as _),)*]) + <::hashbrown::HashMap::<_, _> as ::core::iter::FromIterator<_>>::from_iter([$(($k as _, $v as _),)*]) }; }