From 632b0900ea898de5983f66cbf4c06ebdd2c19d75 Mon Sep 17 00:00:00 2001 From: jofas Date: Sun, 28 Jan 2024 16:21:20 +0100 Subject: [PATCH 1/2] cast keys as well as values for explicitly typed map macros --- src/_std.rs | 4 ++-- src/hashbrown.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 _),)*]) }; } From 18581ed7ed3d0f97f7a96beb557e0ec6fe0493cd Mon Sep 17 00:00:00 2001 From: jofas Date: Sun, 28 Jan 2024 16:23:21 +0100 Subject: [PATCH 2/2] updated changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) 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