mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +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
|
|
}
|