From 1f155bd231fbc4a8fe9c0a1c9758d8e68ae37e5a Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Thu, 2 Dec 2021 18:46:52 -0500 Subject: [PATCH 1/2] fixes --- src/util/pattern.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/pattern.rs b/src/util/pattern.rs index a857bff..7ea35d6 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -8,11 +8,12 @@ type ParseError = Box; trait Pattern<'a> { pub fn execute(&self, values: &'a mut [RawColor]); - pub fn parse(args: Vec) -> Result; + pub fn parse(args: Vec) -> Result where Self: Sized; } impl<'a> TryFrom> for Box> { - fn try_from(s: Vec) -> Result { + type Error = ParseError; + fn try_from(s: Vec) -> Result { match s[0].as_str() { "unit" => Unit::parse(s), "val" => Value::parse(s), @@ -96,4 +97,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 +} From 3a00c4bb09dbefb9b2644002bb8c622f2e00a3b0 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Thu, 2 Dec 2021 19:01:16 -0500 Subject: [PATCH 2/2] fix all errors in pattern in pattern --- src/util/pattern.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/pattern.rs b/src/util/pattern.rs index 7ea35d6..e8d37d0 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -6,17 +6,17 @@ use std::{ type ParseError = Box; -trait Pattern<'a> { - pub fn execute(&self, values: &'a mut [RawColor]); - pub fn parse(args: Vec) -> Result where Self: Sized; +pub trait Pattern<'a> { + fn execute(&self, values: &'a mut [RawColor]); + fn parse(args: Vec) -> Result where Self: Sized; } 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" => Unit::parse(s), - "val" => Value::parse(s), + "unit" => Ok(Box::new(Unit::parse(s).unwrap()) as Box), + "val" => Ok(Box::new(Value::parse(s).unwrap()) as Box), _ => Err("No Match".into()) } } @@ -88,7 +88,7 @@ impl<'a> Pattern<'a> for Value { }) } }, - Err(e) => Err(e) + Err(e) => Err(Box::new(e)) } } }