()
| 5 | use std::rc::Rc; |
| 6 | |
| 7 | fn 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 | } |