We have a simple pattern of "get or create" which I was able to implement as shown below. However, we couldn't find an efficient way to avoid this insert
followed by get
of the value which we just created. Is there a way to write this in a more concise way?
let value = match map.get_mut(key) {
Some(v) => v,
None => {
let v = Value::new();
map.insert(key.to_owned(), v);
map.get_mut(key).unwrap()
}
};