hashmap_to_hashmap

Crates.iohashmap_to_hashmap
lib.rshashmap_to_hashmap
version0.9.0
sourcesrc
created_at2016-01-20 09:58:43.319108
updated_at2016-01-20 09:58:43.319108
descriptionAdds a method .map to HashMap that maps to another HashMap
homepage
repositoryhttps://github.com/bradurani/rust-hashmap-to-hashmap
max_upload_size
id3934
size3,690
Brad Urani (bradurani)

documentation

README

HashMap to HashMap

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" }
Commit count: 5

cargo fmt