1use std::fmt;
2
3struct Point {
4 x: i32,
5 y: i32,
6}
7
8impl fmt::Display for Point {
9 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10 write!(f, "({}, {})", self.x, self.y)
11 }
12}
13
14let origin = Point { x: 0, y: 0 };
15
16assert_eq!(format!("The origin is: {}", origin), "The origin is: (0, 0)");Run