From 7b8081a79fb3db4a76f9e4cca8f8a88e6e7f873c Mon Sep 17 00:00:00 2001 From: Genny Date: Wed, 15 Sep 2021 22:16:30 -0500 Subject: Reading, fix writing, monocommit --- src/color.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/color.rs') diff --git a/src/color.rs b/src/color.rs index dc134ef..764acaf 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,11 +1,22 @@ +#[derive(Copy, Clone, Debug)] pub struct Color { - pub r: u8, - pub g: u8, - pub b: u8 + pub r: u8, + pub g: u8, + pub b: u8, } impl Color { - pub fn new(r: u8, g: u8, b: u8) -> Self { - Self { r, g, b } - } -} \ No newline at end of file + pub fn new(r: u8, g: u8, b: u8) -> Self { + Self { r, g, b } + } +} + +impl From<[u8; 3]> for Color { + fn from(arr: [u8; 3]) -> Self { + Self { + r: arr[0], + g: arr[1], + b: arr[2], + } + } +} -- cgit 1.4.1-3-g733a5