From 637441239434fabedfe83f5abc1af4232c802f7a Mon Sep 17 00:00:00 2001 From: Genny Date: Thu, 23 Sep 2021 20:33:50 -0500 Subject: Improve API, monocommit, sorry --- src/color.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/color.rs') diff --git a/src/color.rs b/src/color.rs index 764acaf..dd96280 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,4 +1,4 @@ -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq)] pub struct Color { pub r: u8, pub g: u8, @@ -20,3 +20,19 @@ impl From<[u8; 3]> for Color { } } } + +impl From<(u8, u8, u8)> for Color { + fn from(t: (u8, u8, u8)) -> Self { + Self { + r: t.0, + g: t.1, + b: t.2, + } + } +} + +impl Into<[u8; 3]> for Color { + fn into(self) -> [u8; 3] { + [self.r, self.g, self.b] + } +} -- cgit 1.4.1-3-g733a5