mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
19 lines
258 B
Rust
19 lines
258 B
Rust
// run-pass
|
|
|
|
fn f(arg: &mut A) {
|
|
arg.a = 100;
|
|
}
|
|
|
|
#[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);
|
|
}
|