From a90cd5cc6b537895edb94b18544cfb0fd975ebd1 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 1 Oct 2018 20:35:20 -0600 Subject: [PATCH] annotate --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index 274f97c..b4ec3ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ fn main() { thread::spawn(move || { { + // in a subscope to release borrow automatically let mut count = counter.lock().unwrap(); *count += 1; } @@ -32,6 +33,7 @@ fn handle_connection(counter: Arc>, mut stream: TcpStream) { stream.read(&mut buffer).unwrap(); { + // in a subscope to unlock automatically let count = counter.lock().unwrap(); println!("Request: {}\n{}", count, String::from_utf8_lossy(&buffer[..])); }