diff --git a/docs/src/tutorial/all_together.md b/docs/src/tutorial/all_together.md index a638e02..641c7da 100644 --- a/docs/src/tutorial/all_together.md +++ b/docs/src/tutorial/all_together.md @@ -115,7 +115,8 @@ async fn broker(mut events: Receiver) -> Result<()> { Event::Message { from, to, msg } => { for addr in to { if let Some(peer) = peers.get_mut(&addr) { - peer.send(format!("from {}: {}\n", from, msg)).await? + let msg = format!("from {}: {}\n", from, msg); + peer.send(msg).await? } } } diff --git a/docs/src/tutorial/clean_shutdown.md b/docs/src/tutorial/clean_shutdown.md index f61adf2..992a35d 100644 --- a/docs/src/tutorial/clean_shutdown.md +++ b/docs/src/tutorial/clean_shutdown.md @@ -115,7 +115,8 @@ Let's add waiting to the server: # Event::Message { from, to, msg } => { # for addr in to { # if let Some(peer) = peers.get_mut(&addr) { -# peer.send(format!("from {}: {}\n", from, msg)).await? +# let msg = format!("from {}: {}\n", from, msg); +# peer.send(msg).await? # } # } # } @@ -217,7 +218,8 @@ async fn broker(mut events: Receiver) -> Result<()> { Event::Message { from, to, msg } => { for addr in to { if let Some(peer) = peers.get_mut(&addr) { - peer.send(format!("from {}: {}\n", from, msg)).await? + let msg = format!("from {}: {}\n", from, msg); + peer.send(msg).await? } } } diff --git a/docs/src/tutorial/connecting_readers_and_writers.md b/docs/src/tutorial/connecting_readers_and_writers.md index 7399cec..d5da471 100644 --- a/docs/src/tutorial/connecting_readers_and_writers.md +++ b/docs/src/tutorial/connecting_readers_and_writers.md @@ -73,7 +73,8 @@ async fn broker(mut events: Receiver) -> Result<()> { Event::Message { from, to, msg } => { // 3 for addr in to { if let Some(peer) = peers.get_mut(&addr) { - peer.send(format!("from {}: {}\n", from, msg)).await? + let msg = format!("from {}: {}\n", from, msg); + peer.send(msg).await? } } } diff --git a/docs/src/tutorial/handling_disconnection.md b/docs/src/tutorial/handling_disconnection.md index 351f253..82bbef5 100644 --- a/docs/src/tutorial/handling_disconnection.md +++ b/docs/src/tutorial/handling_disconnection.md @@ -257,7 +257,8 @@ async fn broker(events: Receiver) { Event::Message { from, to, msg } => { for addr in to { if let Some(peer) = peers.get_mut(&addr) { - peer.send(format!("from {}: {}\n", from, msg)).await + let msg = format!("from {}: {}\n", from, msg); + peer.send(fmt).await .unwrap() // 6 } } diff --git a/examples/a-chat/server.rs b/examples/a-chat/server.rs index 911d160..77ebfd1 100644 --- a/examples/a-chat/server.rs +++ b/examples/a-chat/server.rs @@ -139,9 +139,8 @@ async fn broker_loop(mut events: Receiver) { Event::Message { from, to, msg } => { for addr in to { if let Some(peer) = peers.get_mut(&addr) { - peer.send(format!("from {}: {}\n", from, msg)) - .await - .unwrap() + let msg = format!("from {}: {}\n", from, msg); + peer.send(msg).await.unwrap(); } } } diff --git a/examples/socket-timeouts.rs b/examples/socket-timeouts.rs index b2f770e..894206c 100644 --- a/examples/socket-timeouts.rs +++ b/examples/socket-timeouts.rs @@ -10,7 +10,7 @@ async fn get() -> io::Result> { let mut buf = vec![]; - io::timeout(Duration::from_secs(5), async { + io::timeout(Duration::from_secs(5), async move { stream.read_to_end(&mut buf).await?; Ok(buf) })