1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
struct Foo { pub v: Vec<String> } fn main() { let f = Foo { v: Vec::new() }; f.v.push("cat".to_string()); //~ ERROR cannot borrow } struct S { x: i32, } fn foo() { let s = S { x: 42 }; s.x += 1; //~ ERROR cannot assign } fn bar(s: S) { s.x += 1; //~ ERROR cannot assign }