Skip to content

Commit ac465a2

Browse files
authored
Merge pull request #38 from jofas/explicitly-cast-macros-keys-also-casted
Cast keys as well as values for explicitly typed map macros
2 parents 8bc48dd + 18581ed commit ac465a2

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
* `hashbrown::hash_set` macro
1616

17+
### Changed
18+
19+
* Explicitly typed map macros: keys also cast now (before only values were
20+
casted)
21+
1722
### Removed
1823

1924
* `map` macro

src/_std.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro_rules! hash_map {
4646
#[macro_export]
4747
macro_rules! hash_map_e {
4848
{$($k: expr => $v: expr),* $(,)?} => {
49-
::std::collections::HashMap::from([$(($k, $v as _),)*])
49+
::std::collections::HashMap::from([$(($k as _, $v as _),)*])
5050
};
5151
}
5252

@@ -96,7 +96,7 @@ macro_rules! btree_map {
9696
#[macro_export]
9797
macro_rules! btree_map_e {
9898
{$($k: expr => $v: expr),* $(,)?} => {
99-
::std::collections::BTreeMap::from([$(($k, $v as _),)*])
99+
::std::collections::BTreeMap::from([$(($k as _, $v as _),)*])
100100
};
101101
}
102102

src/hashbrown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ macro_rules! __hb_hash_map {
7171
#[macro_export]
7272
macro_rules! __hb_hash_map_e {
7373
{$($k: expr => $v: expr),* $(,)?} => {
74-
<::hashbrown::HashMap::<_, _> as ::core::iter::FromIterator<_>>::from_iter([$(($k, $v as _),)*])
74+
<::hashbrown::HashMap::<_, _> as ::core::iter::FromIterator<_>>::from_iter([$(($k as _, $v as _),)*])
7575
};
7676
}
7777

0 commit comments

Comments
 (0)