1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Tests that auto-ref can't create mutable aliases to immutable memory. struct Foo { x: isize } impl Foo { pub fn printme(&mut self) { println!("{}", self.x); } } fn main() { let x = Foo { x: 3 }; x.printme(); //~ ERROR cannot borrow }