mirror of
				https://github.com/LukasKalbertodt/programmieren-in-rust.git
				synced 2025-11-04 02:10:41 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			16 lines
		
	
	
		
			372 B
		
	
	
	
		
			Rust
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			372 B
		
	
	
	
		
			Rust
		
	
	
		
			Executable File
		
	
	
	
	
 | 
						|
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);
 | 
						|
}
 |