fixes
This commit is contained in:
parent
23e4aa8471
commit
1f155bd231
1 changed files with 4 additions and 3 deletions
|
@ -8,11 +8,12 @@ type ParseError = Box<dyn std::error::Error>;
|
|||
|
||||
trait Pattern<'a> {
|
||||
pub fn execute(&self, values: &'a mut [RawColor]);
|
||||
pub fn parse(args: Vec<String>) -> Result<Self, ParseError>;
|
||||
pub fn parse(args: Vec<String>) -> Result<Self, ParseError> where Self: Sized;
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<Vec<String>> for Box<dyn Pattern<'a>> {
|
||||
fn try_from(s: Vec<String>) -> Result<Self, ParseError> {
|
||||
type Error = ParseError;
|
||||
fn try_from(s: Vec<String>) -> Result<Self, Error> {
|
||||
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<String>) -> Result<Box<dyn Pattern<'static>>, ParseError> {
|
||||
let res: Result<Box<dyn Pattern>, ParseError> = v.try_into();
|
||||
res
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue