mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
22 lines
304 B
Rust
22 lines
304 B
Rust
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
|
|
}
|