Warning
This post was published 56 days ago. The information described in this article may have changed.
I read an-alias-based-formulation-of-the-borrow-checker, but the article doesn't mention:
Take the following example:
use std::collections::HashMap;
use std::hash::Hash;
fn get_default<'r, K, V>(map: &'r mut HashMap<K, V>, key: K) -> &'r mut V
where K: Clone + Eq + Hash, V: Default + Clone,
{
match map.get_mut(&key) {
Some(value) => { /* nothing... */ }
None => {
map.insert(key.clone(), V::default());
return map.get_mut(&key).unwrap();
}
}
map.get_mut(&key).unwrap()
}
In this example, the origin of the input and output references is the same, and reborrows also occur. I'd like to understand how Polonius operates on the CFG corresponding to this code.
Thank you very much for your help.
1 post - 1 participant
🏷️ rust_feed