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

Function main

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

Source from the content-addressed store, hash-verified

1use std::collections::HashMap;
2
3fn main() {
4 let mut d: HashMap<String, Vec<i32>> = HashMap::new();
5
6 d.entry("banana".to_string())
7 .or_insert_with(Vec::new)
8 .push(0);
9 println!("{:?}", d);
10 for k in d.keys() {
11 println!("{:?}", k);
12 }
13 for v in d.values() {
14 println!("{:?}", v);
15 }
16
17 let mut td: HashMap<(i32, i32), Vec<i32>> = HashMap::new();
18 td.insert((0, 1), vec![]);
19}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected