filtering empty lines

This commit is contained in:
Fernando Herrera 2021-09-23 20:44:50 +01:00
parent 04990eeba4
commit cb9db792a6

View File

@ -39,9 +39,13 @@ impl Command for Lines {
.map(|s| s.to_string())
.collect::<Vec<String>>();
let iter = lines
.into_iter()
.map(move |s| Value::String { val: s, span });
let iter = lines.into_iter().filter_map(move |s| {
if !s.is_empty() {
Some(Value::String { val: s, span })
} else {
None
}
});
Value::Stream {
stream: ValueStream(Rc::new(RefCell::new(iter))),