Skip to content

Commit

Permalink
cast keys as well as values for explicitly typed map macros
Browse files Browse the repository at this point in the history
  • Loading branch information
jofas committed Jan 28, 2024
1 parent 8bc48dd commit 632b090
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _),)*])
};
}

Expand Down Expand Up @@ -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 _),)*])
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/hashbrown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _),)*])
};
}

Expand Down

0 comments on commit 632b090

Please sign in to comment.