rust/src/test/run-pass/expr-copy.rs
2012-03-26 18:35:18 -07:00

13 lines
169 B
Rust

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;
}