Add a way of safely doing an upsert in CHashMap
Created by: brendanzab
I would like to be able to do something like this:
let map = CHashMap::new();
// ...
let values = vec![1, 2, 3];
match map.get_mut(&"x") {
None => { map.insert("x", values); }
Some(mut existing) => existing.extend(values),
}
I'm assuming another thread might be able to insert an entry into map
between the time of the lookup and the call to CHashMap::insert
. This would cause that previous entry to be discarded. It would be nice to be able to ensure this would not happen!