diff --git a/src/bin/echo.rs b/src/bin/echo.rs index f8b412f70..ccd947522 100644 --- a/src/bin/echo.rs +++ b/src/bin/echo.rs @@ -31,8 +31,9 @@ fn main() { // 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 (reader, writer) = TaskIo::new(socket).split(); - let amt = copy(reader, writer); + 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)); // Once all that is done we print out how much we wrote, and then // critically we *forget* this future which allows it to run