From dafac3d248d69cdb9830244f7d0e2240b9c2cc94 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Tue, 28 Dec 2021 15:12:33 -0500 Subject: [PATCH] Revert "ret" This reverts commit 7ea486dea68bd9ba27719fbc4a75618ded20c57b. --- src/main.rs | 4 ++-- src/util/pattern.rs | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index e354b99..ac3ce0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,14 +34,14 @@ fn main() { thread::sleep(time::Duration::from_millis(250)); let mut lights = lock.write().unwrap(); let pattern = format_multiline("unit"); - let res: Result>, ParseError> = pattern.iter() + let res: Result>> = pattern.iter() .map(|x: &Vec| parse_line((*x).clone())) .collect(); if res.is_ok() { let v: Vec> = res.unwrap(); for x in 0..v.len() { - lights = *(v[x].execute(&mut lights)); + v[x].execute(&mut lights); } } } diff --git a/src/util/pattern.rs b/src/util/pattern.rs index 4f42ff9..ce732f1 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -8,7 +8,7 @@ use std::sync::RwLockWriteGuard; pub type ParseError = Box; pub trait Pattern<'a> { - fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) -> &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>; + fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>); fn parse(args: Vec) -> Result where Self: Sized; } @@ -25,9 +25,7 @@ impl<'a> TryFrom> for Box> { struct Unit; impl<'a> Pattern<'a> for Unit { - fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) -> &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]> { - values - } + fn execute(&self, _values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) {} fn parse(_args: Vec) -> Result { Ok(Unit {}) } @@ -40,7 +38,7 @@ struct Value { } impl<'a> Pattern<'a> for Value { - fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) -> &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]> { + fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor; crate::LED_SIZE]>) { for i in 0..crate::LED_SIZE { let mut color: RawColor = (*values)[i]; if self.r.is_some() { @@ -54,7 +52,6 @@ impl<'a> Pattern<'a> for Value { } (*values)[i] = color; } - values } fn parse(args: Vec) -> Result { let param1 = args[1].parse::();