derive rust code example
Example: rust non derived debug trait example
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Debug for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y)
}
}
let origin = Point { x: 0, y: 0 };
println!("The origin is: {:?}", origin);