MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / main

Function main

publication/code/chapter01/use_refcell.rs:7–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5use std::rc::Rc;
6
7fn main() {
8 let shared_map: Rc<RefCell<_>> =
9 Rc::new(RefCell::new(HashMap::new()));
10 {
11 let mut map: RefMut<_> = shared_map.borrow_mut();
12 map.insert("kew", 1);
13 map.insert("shieber", 2);
14 map.insert("mon", 3);
15 map.insert("hon", 4);
16 }
17
18 let total: i32 = shared_map.borrow().values().sum();
19 println!("{}", total);
20}

Callers

nothing calls this directly

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected