Skip to content

Instantly share code, notes, and snippets.

@hosszukalman
Created December 5, 2016 09:00
Show Gist options
  • Save hosszukalman/228a9e89e0693ab71cef88e169c13ca3 to your computer and use it in GitHub Desktop.
Save hosszukalman/228a9e89e0693ab71cef88e169c13ca3 to your computer and use it in GitHub Desktop.
#[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