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