1 | extern crate overload; |
---|---|
2 | use overload::overload; |
3 | use std::ops; |
4 | |
5 | #[derive(PartialEq, Debug)] |
6 | struct A(i32); |
7 | |
8 | #[derive(PartialEq, Debug)] |
9 | struct B(i32); |
10 | |
11 | overload!(- (a: A) -> B { B(-a.0) }); |
12 | #[test] |
13 | fn neg() { |
14 | assert_eq!(-A(3), B(-3)); |
15 | } |
16 | |
17 | overload!(! (a: A) -> B { B(!a.0) }); |
18 | #[test] |
19 | fn not() { |
20 | assert_eq!(!A(3), B(!3)); |
21 | } |
22 |