Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How polonius analyzes code on the CFG
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