1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10 
11 #[cfg(feature = "use_core")]
12 extern crate core;
13 
14 #[macro_use]
15 extern crate derivative;
16 
17 
f(arg: &mut A)18 fn f(arg: &mut A) {
19     arg.a = 100;
20 }
21 
22 #[derive(Derivative)]
23 #[derivative(Copy, Clone)]
24 struct A { a: isize }
25 
26 #[test]
main()27 fn main() {
28     let mut x = A {a: 10};
29     f(&mut x);
30     assert_eq!(x.a, 100);
31     x.a = 20;
32     let mut y = x;
33     f(&mut y);
34     assert_eq!(x.a, 20);
35 }
36