Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused)]
- fn main() {
- use std::ops::Add;
- #[derive(Debug, PartialEq)]
- struct Point {
- x: i32,
- y: i32,
- }
- impl<'a> Add for &'a Point {
- type Output = Point;
- fn add<'b>(self, other: &'b Point) -> Point {
- Point {
- x: self.x + other.x,
- y: self.y + other.y,
- }
- }
- }
- let p1 = Point{ x: 0, y: 1 };
- let p2 = Point{ x: 2, y: 3 };
- let p3 = &p1 + &p2;
- println!("{:?}, {:?}, {:?}", p1, p2, p3);
- }
Add Comment
Please, Sign In to add comment