diff --git a/src/bin/main.rs b/src/bin/main.rs index 4df7945..b3a9141 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -24,11 +24,6 @@ fn main() { let counter = Arc::clone(&counter); tasks.run(move || { - { - // in a subscope to release borrow automatically - let mut count = counter.lock().unwrap(); - *count += 1; - } handle_connection(counter, stream); }); } @@ -44,7 +39,8 @@ fn handle_connection(counter: Arc>, mut stream: TcpStream) { { // in a subscope to unlock automatically - let count = counter.lock().unwrap(); + let mut count = counter.lock().unwrap(); + *count += 1; println!("Request: {}\n{}", count, String::from_utf8_lossy(&buffer[..])); }