RBE hello/print/fmt activity

This commit is contained in:
Dan Buch 2021-09-10 11:18:23 -04:00
parent 8f891c1e73
commit 60da2e20dc
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7

View File

@ -30,6 +30,16 @@ struct Color {
blue: u8,
}
impl Display for Color {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(
f,
"RGB ({}, {}, {}) 0x{:02X}{:02X}{:02X}",
self.red, self.green, self.blue, self.red, self.green, self.blue
)
}
}
fn main() {
for city in [
City {
@ -72,6 +82,6 @@ fn main() {
]
.iter()
{
println!("{:?}", *color);
println!("{}", *color);
}
}