Skip to content

Instantly share code, notes, and snippets.

@ruimo
Created February 25, 2020 08:14
Show Gist options
  • Save ruimo/d395277e3723b0c59e3951227275a2ec to your computer and use it in GitHub Desktop.
Save ruimo/d395277e3723b0c59e3951227275a2ec to your computer and use it in GitHub Desktop.
use std::fmt;
#[derive(Debug)]
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 p = Point {x: 1, y: 2};
println!("p: {}", p);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment