From a9b53d61d2520715b3867d6c5b11e9f8006265fa Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Sat, 20 Aug 2016 11:52:16 -0400 Subject: [PATCH] update comment and simplify echo example --- src/bin/echo.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bin/echo.rs b/src/bin/echo.rs index 338d44d46..f8b412f70 100644 --- a/src/bin/echo.rs +++ b/src/bin/echo.rs @@ -26,16 +26,13 @@ fn main() { println!("Listening on: {}", addr); // Pull out the stream of incoming connections and then for each new - // one spin up a new task copying data. We put the `socket` into a - // `Arc` structure which then allows us to share it across the - // read/write halves with a small shim. + // one spin up a new task copying data. // - // Finally we use the `io::copy` future to copy all data from the + // We use the `io::copy` future to copy all data from the // reading half onto the writing half. socket.incoming().for_each(|(socket, addr)| { - let socket = futures::lazy(|| futures::finished(TaskIo::new(socket))); - let pair = socket.map(|s| s.split()); - let amt = pair.and_then(|(reader, writer)| copy(reader, writer)); + let (reader, writer) = TaskIo::new(socket).split(); + let amt = copy(reader, writer); // Once all that is done we print out how much we wrote, and then // critically we *forget* this future which allows it to run