MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / main

Function main

08_hashmaps/rust/hashmap.rs:3–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1use std::collections::HashMap; // also look at BTreeMap
2
3fn main() {
4 let literal: HashMap<_, _> = vec![("key", "value"), ("blah", "blubb")]
5 .into_iter()
6 .collect();
7 println!("{:?}", literal);
8
9 let mut mutable = HashMap::new();
10 mutable.insert("one", 1);
11 mutable.insert("two", 2);
12 mutable.remove("one");
13 println!("{:?}", mutable.get("one"));
14 println!("{:?}", mutable.get("two"));
15
16 mutable.insert("three", 3);
17 for (k, v) in &mutable {
18 println!("{}: {}", k, v);
19 }
20}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected