Add solution sheet9

This commit is contained in:
Lukas Kalbertodt
2017-01-09 18:43:34 +01:00
parent 2c45536be8
commit 68d838f8b6
3 changed files with 93 additions and 0 deletions

15
aufgaben/sheet9/sol3/map.rs Executable file
View File

@ -0,0 +1,15 @@
macro_rules! hash_map {
( $($key:expr => $value:expr ,)* ) => {{
let mut map = ::std::collections::HashMap::new();
$( map.insert($key, $value); )*
map
}};
( $($key:expr => $value:expr),* ) => { hash_map!($($key => $value ,)*) };
}
fn main() {
let ages = hash_map!{ "Sabine" => 26, "Peter" => 32 };
println!("{:#?}", ages);
}