From 4c2c072fffc7063644158d88a80d1dc99f61908e Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sun, 24 Jan 2016 23:04:56 -0800 Subject: [PATCH] Use non-moving closure, where possible --- tarpc/src/protocol.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tarpc/src/protocol.rs b/tarpc/src/protocol.rs index 13ad1ab..60a009f 100644 --- a/tarpc/src/protocol.rs +++ b/tarpc/src/protocol.rs @@ -251,16 +251,14 @@ pub fn serve_async(addr: A, f: F, read_timeout: Option) -> io::R Ok(c) => c, }; inflight_rpcs.increment(); - let read_stream = conn.try_clone().unwrap(); - let mut handler = ConnectionHandler { - write_stream: Mutex::new(conn), - shutdown: &shutdown, - inflight_rpcs: &inflight_rpcs, - timeout: read_timeout, - }; - let f = &f; - scope.spawn(move || { - if let Err(err) = handler.handle_conn(read_stream, f) { + scope.spawn(|| { + let mut handler = ConnectionHandler { + write_stream: Mutex::new(conn.try_clone().unwrap()), + shutdown: &shutdown, + inflight_rpcs: &inflight_rpcs, + timeout: read_timeout, + }; + if let Err(err) = handler.handle_conn(conn, &f) { info!("ConnectionHandler: err in connection handling: {:?}", err); } });