From 455fff23cba112888facc5a817556ea79109b800 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Sun, 26 Dec 2021 21:32:42 -0500 Subject: [PATCH] rw lock write --- src/util/pattern.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/pattern.rs b/src/util/pattern.rs index e8d37d0..ec06c1d 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -3,11 +3,12 @@ use std::{ vec::Vec, string::String }; +use std::sync::RwLockWriteGuard; type ParseError = Box; pub trait Pattern<'a> { - fn execute(&self, values: &'a mut [RawColor]); + fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor]>); fn parse(args: Vec) -> Result where Self: Sized; } @@ -24,7 +25,7 @@ impl<'a> TryFrom> for Box> { struct Unit; impl<'a> Pattern<'a> for Unit { - fn execute(&self, values: &'a mut [RawColor]) {} + fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor]>) {} fn parse(args: Vec) -> Result { Ok(Unit {}) } @@ -37,9 +38,9 @@ struct Value { } impl<'a> Pattern<'a> for Value { - fn execute(&self, values: &'a mut [RawColor]) { + fn execute(&self, values: &'a mut RwLockWriteGuard<'_, [RawColor]>) { for i in 0..crate::LED_SIZE { - let color: RawColor = values[i]; + let color: RawColor = *values[i]; if self.r.is_some() { color[0] = self.r.unwrap(); } @@ -49,7 +50,7 @@ impl<'a> Pattern<'a> for Value { if self.b.is_some() { color[0] = self.b.unwrap(); } - values[i] = color; + *values[i] = color; } } fn parse(args: Vec) -> Result {