fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2#![allow(unused_mut)] 3#![allow(dead_code)] 4 5#[derive(Debug)] 6struct A { 7 a: i32, 8} 9 10impl A { 11 fn double(&mut self) { 12 self.a += self.a 13 } 14} 15 16fn baz() { 17 let mut v = [A { a: 4 }]; 18 v.iter_mut().for_each(|a| a.double()); 19 //~^ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference 20 println!("{:?}", v); 21} 22 23fn bar() { 24 let mut v = [A { a: 4 }]; 25 v.iter_mut().rev().rev().for_each(|a| a.double()); 26 //~^ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference 27 println!("{:?}", v); 28} 29 30fn main() {}