use std::fmt;↵
↵
struct Point {↵
x: i32,↵
y: i32,↵
}↵
↵
impl fmt::Display for Point {↵
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {↵
write!(f, "({}, {})", self.x, self.y)↵
}↵
}↵
↵
impl fmt::Debug for Point {↵
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {↵
write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y)↵
}↵
}↵
↵
fn main() {↵
let p = Point { x: 3, y: 4 };↵
println!("{}", p);↵
println!("{:?}", p);↵
}