rust/tests/ui/expr-copy.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
259 B
Rust
Raw Normal View History

//@ run-pass
fn f(arg: &mut A) {
arg.a = 100;
}
2015-03-30 13:38:27 +00:00
#[derive(Copy, Clone)]
struct A { a: isize }
pub fn main() {
let mut x = A {a: 10};
f(&mut x);
assert_eq!(x.a, 100);
x.a = 20;
let mut y = x;
f(&mut y);
assert_eq!(x.a, 20);
}