diff options
Diffstat (limited to 'vendor/derive_more/tests/sum.rs')
-rw-r--r-- | vendor/derive_more/tests/sum.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/derive_more/tests/sum.rs b/vendor/derive_more/tests/sum.rs new file mode 100644 index 000000000..a0b0967bd --- /dev/null +++ b/vendor/derive_more/tests/sum.rs @@ -0,0 +1,31 @@ +#[macro_use] +extern crate derive_more; + +#[derive(Sum)] +struct MyInts(i32, i64); + +// Add implementation is needed for Sum +impl ::core::ops::Add for MyInts { + type Output = MyInts; + #[inline] + fn add(self, rhs: MyInts) -> MyInts { + MyInts(self.0.add(rhs.0), self.1.add(rhs.1)) + } +} + +#[derive(Sum)] +struct Point2D { + x: i32, + y: i32, +} + +impl ::core::ops::Add for Point2D { + type Output = Point2D; + #[inline] + fn add(self, rhs: Point2D) -> Point2D { + Point2D { + x: self.x.add(rhs.x), + y: self.y.add(rhs.y), + } + } +} |