RosettaCodeData/Task/Associative-array-Iteration/Rust/associative-array-iteration.rust
2015-02-20 00:35:01 -05:00

16 lines
385 B
Text

use std::collections::HashMap;
fn main() {
let mut squares = HashMap::new();
squares.insert("one", 1i32);
squares.insert("two", 4);
squares.insert("three", 9);
for key in squares.keys() {
println!("Key {}", key);
}
for value in squares.values() {
println!("Value {}", value);
}
for (key, value) in squares.iter() {
println!("{} => {}", key, value);
}
}