diff --git a/src/util/pattern.rs b/src/util/pattern.rs index e8d37d0..a857bff 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -6,17 +6,16 @@ use std::{ type ParseError = Box; -pub trait Pattern<'a> { - fn execute(&self, values: &'a mut [RawColor]); - fn parse(args: Vec) -> Result where Self: Sized; +trait Pattern<'a> { + pub fn execute(&self, values: &'a mut [RawColor]); + pub fn parse(args: Vec) -> Result; } impl<'a> TryFrom> for Box> { - type Error = ParseError; - fn try_from(s: Vec) -> Result { + fn try_from(s: Vec) -> Result { match s[0].as_str() { - "unit" => Ok(Box::new(Unit::parse(s).unwrap()) as Box), - "val" => Ok(Box::new(Value::parse(s).unwrap()) as Box), + "unit" => Unit::parse(s), + "val" => Value::parse(s), _ => Err("No Match".into()) } } @@ -88,7 +87,7 @@ impl<'a> Pattern<'a> for Value { }) } }, - Err(e) => Err(Box::new(e)) + Err(e) => Err(e) } } } @@ -97,4 +96,4 @@ impl<'a> Pattern<'a> for Value { pub fn parse_line(v: Vec) -> Result>, ParseError> { let res: Result, ParseError> = v.try_into(); res -} +} \ No newline at end of file