Created
February 25, 2020 08:14
-
-
Save ruimo/d395277e3723b0c59e3951227275a2ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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