Created
December 5, 2016 09:00
-
-
Save hosszukalman/228a9e89e0693ab71cef88e169c13ca3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#[derive(Debug)] | |
struct Color { | |
red: u8, | |
green: u8, | |
blue: u8, | |
} | |
impl fmt::Display for Color { | |
// `f` is a buffer, this method must write the formatted string into it | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
write!(f, "RGB ({0}, {1}, {2}) 0X{0:02.X}{1:02.X}{2:02.X}", | |
self.red, self.green, self.blue) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment