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

15 lines
187 B
Rust
Raw Normal View History

#[legacy_modes];
2012-03-26 18:35:18 -07:00
fn f(arg: {mut a: int}) {
arg.a = 100;
}
fn main() {
2012-03-26 18:35:18 -07:00
let x = {mut a: 10};
f(x);
assert x.a == 100;
x.a = 20;
f(copy x);
assert x.a == 20;
}