collections
This commit is contained in:
parent
870750151d
commit
2de3ecde06
2 changed files with 12 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
@ -34,9 +34,12 @@ fn main() {
|
||||||
thread::sleep(time::Duration::from_millis(250));
|
thread::sleep(time::Duration::from_millis(250));
|
||||||
let mut lights = lock.write().unwrap();
|
let mut lights = lock.write().unwrap();
|
||||||
let pattern = format_multiline("val 255 150 0");
|
let pattern = format_multiline("val 255 150 0");
|
||||||
let res = parse_line(pattern);
|
pattern.iter()
|
||||||
if res.is_ok() {
|
.map(|x| parse_line(x))
|
||||||
res.unwrap().execute(&mut lights);
|
.for_each(|res| {
|
||||||
}
|
if res.is_ok() {
|
||||||
|
res.unwrap().execute(&mut lights);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,10 @@ pub fn parse_line<'a>(v: Vec<String>) -> Result<Box<dyn Pattern<'a>>, ParseError
|
||||||
|
|
||||||
pub fn format_multiline(input: &str) -> Vec<Vec<String>> {
|
pub fn format_multiline(input: &str) -> Vec<Vec<String>> {
|
||||||
input.lines()
|
input.lines()
|
||||||
.map(|x: &str| x.split_whitespace().collect::<Vec<String>>())
|
.map(|x: &str|
|
||||||
|
x.split_whitespace()
|
||||||
|
.map(|y| String::from(y))
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
Loading…
Reference in a new issue