nushell/src/commands/to_array.rs

18 lines
498 B
Rust
Raw Normal View History

2019-05-16 00:58:44 +02:00
use crate::object::Value;
2019-05-13 23:00:25 +02:00
use crate::prelude::*;
pub fn to_array(args: CommandArgs) -> Result<OutputStream, ShellError> {
let out = args.input.collect();
Ok(out
.map(|vec: Vec<_>| single_output(Value::List(vec)))
.flatten_stream()
.boxed())
2019-05-13 23:00:25 +02:00
}
2019-05-15 18:12:38 +02:00
crate async fn stream_to_array(stream: InputStream) -> InputStream {
let out = Value::List(stream.collect().await);
2019-05-15 18:12:38 +02:00
let mut stream = VecDeque::new();
stream.push_back(out);
stream.boxed() as InputStream
2019-05-15 18:12:38 +02:00
}