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

13 lines
177 B
Rust
Raw Normal View History

fn f(arg: {mutable a: int}) {
arg.a = 100;
}
fn main() {
let x = {mutable a: 10};
f(x);
assert x.a == 100;
x.a = 20;
f(copy x);
assert x.a == 20;
}