1
0
Fork 0
firefox/third_party/rust/derive_more/tests/sum.rs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

32 lines
611 B
Rust

#![cfg_attr(not(feature = "std"), no_std)]
use derive_more::Sum;
#[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),
}
}
}