Since there's a vec! in the standard library, should we also include some
macro for HashMaps/Dictionaries? Here's an example of it's implementation
and usage:
#![feature(macro_rules)]
extern crate collections;
macro_rules! dict(
($($key:expr => $val:expr),*) => ({
let mut h = collections::HashMap::new();
$(
h.insert($key, $val);
)*
h
})
)
fn main() {
let d = dict!["key1" => "value1", "key2" => "value2"];
for (k, v) in d.iter() {
println!("{}: {}", k, v);
}
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev