From 781bd23de1eba2b2501ecb5f126894423a1415ff Mon Sep 17 00:00:00 2001 From: Rafael Bachmann Date: Fri, 13 Dec 2024 22:23:49 +0100 Subject: [PATCH] docs: replace match guards by pattern matching in examples --- README.md | 2 +- tokio/README.md | 2 +- tokio/src/lib.rs | 2 +- tokio/src/runtime/mod.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6ba7d7f44e4..ea81cc7c7a0 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box> { loop { let n = match socket.read(&mut buf).await { // socket closed - Ok(n) if n == 0 => return, + Ok(0) => return, Ok(n) => n, Err(e) => { eprintln!("failed to read from socket; err = {:?}", e); diff --git a/tokio/README.md b/tokio/README.md index 6ba7d7f44e4..ea81cc7c7a0 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box> { loop { let n = match socket.read(&mut buf).await { // socket closed - Ok(n) if n == 0 => return, + Ok(0) => return, Ok(n) => n, Err(e) => { eprintln!("failed to read from socket; err = {:?}", e); diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 7b84b54b882..b85921f31de 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -284,7 +284,7 @@ //! loop { //! let n = match socket.read(&mut buf).await { //! // socket closed -//! Ok(n) if n == 0 => return, +//! Ok(0) => return, //! Ok(n) => n, //! Err(e) => { //! eprintln!("failed to read from socket; err = {:?}", e); diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index 82bda0dc597..bc00bc0810d 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -36,7 +36,7 @@ //! loop { //! let n = match socket.read(&mut buf).await { //! // socket closed -//! Ok(n) if n == 0 => return, +//! Ok(0) => return, //! Ok(n) => n, //! Err(e) => { //! println!("failed to read from socket; err = {:?}", e); @@ -84,7 +84,7 @@ //! loop { //! let n = match socket.read(&mut buf).await { //! // socket closed -//! Ok(n) if n == 0 => return, +//! Ok(0) => return, //! Ok(n) => n, //! Err(e) => { //! println!("failed to read from socket; err = {:?}", e);