You can implement Display for custom structs, to print them in the regular manner:
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)
}
}
fn main() {
let point = Point { x: 10, y: 20 };
println!("{}", point); // using standard println!
}
You can also implement things like Add, Sub, AddAssign (point_a += point_b)... :)