This commit is contained in:
jane 2021-12-26 21:13:11 -05:00
parent 6508fe03e2
commit 23e4aa8471

View file

@ -7,8 +7,8 @@ use std::{
type ParseError = Box<dyn std::error::Error>;
trait Pattern<'a> {
fn execute(&self, values: &'a mut [RawColor]);
fn parse(args: Vec<String>) -> Result<Self, ParseError>;
pub fn execute(&self, values: &'a mut [RawColor]);
pub fn parse(args: Vec<String>) -> Result<Self, ParseError>;
}
impl<'a> TryFrom<Vec<String>> for Box<dyn Pattern<'a>> {
@ -48,7 +48,7 @@ impl<'a> Pattern<'a> for Value {
if self.b.is_some() {
color[0] = self.b.unwrap();
}
values[i]
values[i] = color;
}
}
fn parse(args: Vec<String>) -> Result<Self, ParseError> {
@ -57,9 +57,9 @@ impl<'a> Pattern<'a> for Value {
let param3 = args[2].parse::<u8>();
if param1.is_ok() && param2.is_ok() && param3.is_ok() {
Ok(Value{
r: param1.unwrap(),
g: param2.unwrap(),
b: param3.unwrap()
r: Some(param1.unwrap()),
g: Some(param2.unwrap()),
b: Some(param3.unwrap())
})
}
else {
@ -87,7 +87,7 @@ impl<'a> Pattern<'a> for Value {
})
}
},
Err() => Err()
Err(e) => Err(e)
}
}
}