Debian Codegraph @

tests/star_forms.rs

raw symbols SCIP
1 /*
2 Copyright ⓒ 2015 rust-custom-derive contributors.
3
4 Licensed under the MIT license (see LICENSE or <http://opensource.org
5 /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
6 <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
7 files in the project carrying such notice may not be copied, modified,
8 or distributed except according to those terms.
9 */
10 #[macro_use] extern crate custom_derive;
11 #[macro_use] extern crate newtype_derive;
12
13 custom_derive! {
14 #[derive(Copy, Clone, Eq, PartialEq, Debug,
15 NewtypeAdd(*),
16 NewtypeNeg(*),
17 NewtypeFrom
18 )]
19 pub struct Dummy(i32);
20 }
21
22 custom_derive! {
23 #[derive(Copy, Clone, Eq, PartialEq, Debug,
24 NewtypeAdd(*),
25 NewtypeNeg(*),
26 NewtypeFrom
27 )]
28 pub struct DummyPub(pub i32);
29 }
30
31 #[test]
32 fn test_arith() {
33 let a = Dummy::from(4);
34 let b = Dummy::from(7);
35 let c = Dummy::from(11);
36
37 assert_eq!(a + b, c);
38 assert_eq!(&a + b, c);
39 assert_eq!(a + &b, c);
40 assert_eq!(&a + &b, c);
41
42 assert_eq!(-a, Dummy::from(-4));
43 assert_eq!(-&a, Dummy::from(-4));
44
45 let _ = DummyPub(0);
46 }