语法问题。
已有代码
use std::fmt::Display;
use std::ops::Add;
// #[derive(Debug)]
struct Point<T: Add<Output = T>> {
x: T,
y: T,
}
impl<T: Add<Output = T>> Add for Point<T> {
type Output = Point<T>;
fn add(self, other_point: Point<T>) -> Point<T> {
Point {
x: self.x + other_point.x,
y: self.y + other_point.y,
}
}
}
impl<T> Display for Point<T>{
}
fn main() {
let a = Point { x: 1.0, y: 1.0 };
let b = Point { x: 3.0, y: 4.0 };
let c = a + b;
println!("{:?}", c);
}
想请问下,impl Display for Point<T> 正确写法是啥样的?