From 0cb09fbda928e9328ff926c1c4661ae1fda27d0f Mon Sep 17 00:00:00 2001 From: Mingun Date: Thu, 6 Jun 2024 22:56:54 +0500 Subject: [PATCH] Use `if let` instead of `match` (Review in whitespace changes ignored mode) --- src/reader/buffered_reader.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/reader/buffered_reader.rs b/src/reader/buffered_reader.rs index 8aaa5baa..8fbc0ba9 100644 --- a/src/reader/buffered_reader.rs +++ b/src/reader/buffered_reader.rs @@ -112,22 +112,19 @@ macro_rules! impl_buffered_source { } }; - match parser.feed(available) { - Some(i) => { - buf.extend_from_slice(&available[..i]); + if let Some(i) = parser.feed(available) { + buf.extend_from_slice(&available[..i]); - // +1 for `>` which we do not include - self $(.$reader)? .consume(i + 1); - read += i + 1; + // +1 for `>` which we do not include + self $(.$reader)? .consume(i + 1); + read += i + 1; - *position += read; - return Ok(&buf[start..]); - } - None => { - buf.extend_from_slice(available); - available.len() - } + *position += read; + return Ok(&buf[start..]); } + + buf.extend_from_slice(available); + available.len() }; self $(.$reader)? .consume(used); read += used;