This question and code are adapted from Why does creating a mutable reference to a dereferenced mutable reference work?. The answers there explained re-borrowing but not the reasons for the conventions around it.
The two calls to test
below seem equivalent, why does only the first one work?
fn main() {
let mut string = String::new();
let ref_string = &mut string;
// Compiles
test(&mut *ref_string);
// Doesn't compile
test(&mut string);
}
fn test(s: &mut String) {
s.push('t');
}