fn square<T>(x: T) -> T
where
T: std::ops::Add<Output = T> + Copy + std::ops::Mul<Output = T>,
{
let y = x + x;
y * y
}
struct Point<T, U> {
x: T,
y: U,
}
impl<T, U> Point<T, U>
where
T: std::fmt::Debug,
U: std::fmt::Debug,
{
fn printing(&self) {
println!(
"The value of the point coordinates are {:?}, {:?}",
self.x, self.y,
);
}
}
fn main() {
println!("The square of the number is {}", square(5));
println!("The square of the number is {}", square(5.9));
let p1 = Point { x: 5, y: 5 };
let p2 = Point { x: 7.8, y: 8.9 };
let p3 = Point { x: 9, y: 23.1 };
p3.printing();
}