面试题答案
一键面试use std::ops::Add;
struct Point<T, U>
where
T: Add<U, Output = T>,
{
x: T,
y: U,
}
impl<T, U> Point<T, U>
where
T: Add<U, Output = T>,
{
fn sum(&self) -> T {
self.x.clone() + self.y.clone()
}
}
use std::ops::Add;
struct Point<T, U>
where
T: Add<U, Output = T>,
{
x: T,
y: U,
}
impl<T, U> Point<T, U>
where
T: Add<U, Output = T>,
{
fn sum(&self) -> T {
self.x.clone() + self.y.clone()
}
}