Crates.io | hashmap_to_hashmap |
lib.rs | hashmap_to_hashmap |
version | 0.9.0 |
source | src |
created_at | 2016-01-20 09:58:43.319108 |
updated_at | 2016-01-20 09:58:43.319108 |
description | Adds a method .map to HashMap that maps to another HashMap |
homepage | |
repository | https://github.com/bradurani/rust-hashmap-to-hashmap |
max_upload_size | |
id | 3934 |
size | 3,690 |
Adds a method .map
to HashMap that maps to another HashMap
let brad = Person {
id: 1,
first_name: "Brad",
last_name: "Urani",
};
let susan = Person {
id: 2,
first_name: "Susan",
last_name: "Urani",
};
let mut h: HashMap<i32, Person> = HashMap::new();
h.insert(12, brad);
h.insert(29, susan);
let new_map = h.map(|k, v| v.id,
|k, v| k.to_string() + &"-" + &v.first_name + &" " + &v.last_name);
// { 1: "12-Brad Urani", 2: "29-Susan Urani" }