2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
|
|
|
|
2013-02-22 18:08:16 -06:00
|
|
|
fn f(arg: &mut A) {
|
2011-09-12 06:13:20 -05:00
|
|
|
arg.a = 100;
|
|
|
|
}
|
|
|
|
|
2015-03-30 08:38:27 -05:00
|
|
|
#[derive(Copy, Clone)]
|
2015-03-25 19:06:52 -05:00
|
|
|
struct A { a: isize }
|
2013-01-26 00:46:32 -06:00
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2013-02-22 18:08:16 -06:00
|
|
|
let mut x = A {a: 10};
|
|
|
|
f(&mut x);
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(x.a, 100);
|
2011-09-12 06:13:20 -05:00
|
|
|
x.a = 20;
|
2013-06-27 19:41:35 -05:00
|
|
|
let mut y = x;
|
2013-02-22 18:08:16 -06:00
|
|
|
f(&mut y);
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(x.a, 20);
|
2011-09-12 06:13:20 -05:00
|
|
|
}
|