summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 64dd321..a265a30 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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()
+ )
}
}