From b888282e1dc56cd7a63d88e9426488ab2772c0ef Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Sat, 15 Jul 2017 20:45:19 -0700 Subject: with great healp from rschifflin this is way way way way way cleaner (i gotta go back and look at futures::stream::iter and into_iter() vs iter()) and try doing this myself again until i can follow the types a lil better --- main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'main.rs') diff --git a/main.rs b/main.rs index c55eba2..828cc22 100644 --- a/main.rs +++ b/main.rs @@ -121,6 +121,7 @@ fn main() { }; println!("requesting..."); + /* let work = client.request(req).and_then(|res| { res.body().for_each(move |body: hyper::Chunk| { println!("hmmm"); @@ -128,6 +129,13 @@ fn main() { Ok(()) }) }); + */ + + let work = client.request(req).and_then(|res| { + res.body() + .map(|chunk| futures::stream::iter(chunk.into_iter().map(|b| -> Result { Ok(b) }))) + .flatten().for_each(|byte| Ok(print!("{}", byte as char))) + }); println!("Before?"); let resp = core.run(work).unwrap(); -- cgit v1.1