diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -140,13 +140,24 @@ impl AsRef<u32> for Colour { impl std::fmt::Debug for Colour { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - let string: &str = &format!( - "Colour {{ r:{} g:{} b:{} a:{}}}", + write!(f, + "Colour {{ r:{} g:{} b:{}, a:{} }}", self.red(), self.green(), self.blue(), self.alpha() - ); - f.write_str(string) + ) + } +} + +impl std::fmt::Display for Colour { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + write!(f, + "#{:02x}{:02x}{:02x}{:02x}", + self.red(), + self.green(), + self.blue(), + self.alpha() + ) } } |