use std::fmt;
// Define a structure named `Point`
struct Point {
x: i32,
y: i32,
}
// Implement the `fmt::Display` trait for `Point`
impl fmt::Display for Point {
//The fmt::Display trait requires a method fmt which dictates
//how the Point instance should be displayed as a string
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}
fn main() {
let point = Point { x: 1, y: 2 };
println!("{}", point);
}