Borrow checker gets confused with a mutable pointer which should be moved
pub struct FragmentRepr(Vec<FragmentRepr>); pub fn accepted(mut entry: &mut FragmentRepr) { loop { let FragmentRepr(ref mut discrs) = *{entry}; entry = &mut discrs[0]; } } pub fn rejected(mut entry: &mut FragmentRepr) { loop { let FragmentRepr(ref mut discrs) = *entry; entry = &mut discrs[0]; } } fn main() {}
Rust accepts the first function, but rejects the second with "error: cannot borrow entry.0 as mutable more than once at a time". It would be nice not to be forced to insert random curly braces to convince the borrow checker that my code is correct.