Skip to content

Commit ca04a3b

Browse files
committed
Implement basic, incorrect color value serialization.
1 parent 22146ce commit ca04a3b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/color.rs

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ pub enum Color {
3030
RGBAColor(RGBA),
3131
}
3232

33+
impl fmt::Show for Color {
34+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
35+
match self {
36+
&CurrentColor => write!(f, "inherit"),
37+
&RGBAColor(c) => write!(f, "rgba({}, {}, {}, {})", c.red, c.green, c.blue, c.alpha),
38+
};
39+
Ok(())
40+
}
41+
}
3342

3443
/// Return `Err(())` on invalid or unsupported value (not a color).
3544
impl Color {

0 commit comments

Comments
 (0)