rust/src/test/run-pass/expr-copy.rs

15 lines
187 B
Rust

#[legacy_modes];
fn f(arg: {mut a: int}) {
arg.a = 100;
}
fn main() {
let x = {mut a: 10};
f(x);
assert x.a == 100;
x.a = 20;
f(copy x);
assert x.a == 20;
}