You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let mut map = HashMap::new();
for item in &items {
if let Some(values) = map.get_mut(&item) {
values.push(0);
} else {
// This is error now
map.insert(item, vec![0]);
}
}
map is borrowed in if let and being borrowed even if binding failed
The text was updated successfully, but these errors were encountered:
While what you are proposing is potentially useful for other reasons, your specific example can be rewritten to use the entry API (which is additionally more efficient because it only performs one key lookup):
Let's assume code
map is borrowed in
if let
and being borrowed even if binding failedThe text was updated successfully, but these errors were encountered: