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

13 lines
169 B
Rust
Raw Normal View History

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