View all comments
Feature gate: #![feature(hash_map_macro)]
This is a tracking issue for rust-lang/libs-team#578
The hash_map! macro is like the vec! macro but for HashMaps, it aims to help create hash_maps with set keys for functions that require dynamic key value pairs such as a templating engine asking to fill the templates with a HashMap.
Public API
use std::hash_map;
fn main() {
let map = hash_map! {
"key" => "value",
"key2" => "value2"
}; // uses type inference.
for (key, value) in map {
println!("{key:?} => {value:?}");
}
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
Unresolved Questions
View all comments
Feature gate:
#![feature(hash_map_macro)]This is a tracking issue for rust-lang/libs-team#578
The
hash_map!macro is like thevec!macro but forHashMaps, it aims to help create hash_maps with set keys for functions that require dynamic key value pairs such as a templating engine asking to fill the templates with aHashMap.Public API
Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)hash_mapmacro #144070hash_map!macro" #148049 due to regression: hashmap macro stuff #147971hash_map!macro #154322Unresolved Questions
=>,:was also proposed.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩