Express filter as a future
This commit is contained in:
parent
8b0467c1d7
commit
9123d63343
1 changed files with 5 additions and 8 deletions
|
@ -5,7 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
use futures::Stream;
|
use futures::prelude::*;
|
||||||
|
|
||||||
use super::StdinStream;
|
use super::StdinStream;
|
||||||
use webmetro::{
|
use webmetro::{
|
||||||
|
@ -40,11 +40,8 @@ pub fn run(args: &ArgMatches) -> Result<(), Box<Error>> {
|
||||||
chunk_stream = Box::new(chunk_stream.throttle());
|
chunk_stream = Box::new(chunk_stream.throttle());
|
||||||
}
|
}
|
||||||
|
|
||||||
let stdout = io::stdout();
|
let result = chunk_stream.fold((), |_, chunk| {
|
||||||
let mut stdout_writer = stdout.lock();
|
io::stdout().write_all(chunk.as_ref())
|
||||||
for chunk in chunk_stream.wait() {
|
}).wait();
|
||||||
stdout_writer.write_all(chunk?.as_ref())?;
|
result
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue