Implement the std::fmt::Display trait for your type by defining an impl block and providing a fmt method that writes to the formatter.
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)
}
}
Use {} in format strings to print instances of your type.