1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use std::fmt::Display; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] #[repr(C)] pub struct Color { pub a: u8, pub r: u8, pub g: u8, pub b: u8, } impl Display for Color { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( "#{:02x}{:02x}{:02x}{:02x}", self.r, self.g, self.b, self.a )) } }