Hello.
I'd like to share a hashmap using Rc.
My code:
let mut hm: HashMap<String, String> = HashMap::new();
let rc_hm = Rc::new(hm);
let rc_hm_cloned = rc_hm.clone();
let mut borrow_hm = rc_hm_cloned.borrow();
Error:
15 | let mut borrow_hm = rc_hm_cloned.borrow();
| -------------^^^^^^--
| | |
| | cannot infer type for struct `std::rc::Rc<std::collections::HashMap<std::string::String, std::string::String>>`
| this method call resolves to `&Borrowed`
|
= note: cannot satisfy `std::rc::Rc<std::collections::HashMap<std::string::String, std::string::String>>: std::borrow::Borrow<_>`