test collect

This commit is contained in:
jane 2021-12-28 15:00:29 -05:00
parent 0c828a8cf1
commit 1e6f006e10
1 changed files with 11 additions and 8 deletions

View File

@ -32,14 +32,17 @@ fn main() {
});
loop {
thread::sleep(time::Duration::from_millis(250));
let pattern = format_multiline("val 255 150 0");
pattern.iter()
let mut lights = lock.write().unwrap();
let pattern = format_multiline("unit");
let res: Result<Vec<Box<dyn Pattern>>> = pattern.iter()
.map(|x: &Vec<String>| parse_line((*x).clone()))
.for_each(|res: Result<Box<dyn Pattern>, ParseError>| {
if res.is_ok() {
let mut lights = lock.write().unwrap();
res.unwrap().execute(&mut lights);
}
});
.collect();
if res.is_ok() {
let v: Vec<Box<dyn Pattern>> = res.unwrap();
for x in 0..v.len() {
v[x].execute(&mut lights);
}
}
}
}