From: Integral <integral@archlinuxcn.org>
To: kent.overstreet@gmail.com, kent.overstreet@linux.dev,
lihongbo22@huawei.com
Cc: mmpgouride@gmail.com, linux-bcachefs@vger.kernel.org,
integral@archlinuxcn.org
Subject: [PATCH] bcachefs-tools: replace multiple if with match to improve readability
Date: Sun, 27 Oct 2024 22:21:27 +0800 [thread overview]
Message-ID: <20241027142127.110704-1-integral@archlinuxcn.org> (raw)
Replace multiple if expressions with match in Rust code to
improve readability.
Signed-off-by: Integral <integral@archlinuxcn.org>
---
bch_bindgen/src/lib.rs | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/bch_bindgen/src/lib.rs b/bch_bindgen/src/lib.rs
index b68f2d9b..7d65f17a 100644
--- a/bch_bindgen/src/lib.rs
+++ b/bch_bindgen/src/lib.rs
@@ -173,16 +173,11 @@ impl FromStr for c::bpos {
type Err = BchToolsErr;
fn from_str(s: &str) -> Result<Self, Self::Err> {
- if s == "POS_MIN" {
- return Ok(POS_MIN);
- }
-
- if s == "POS_MAX" {
- return Ok(POS_MAX);
- }
-
- if s == "SPOS_MAX" {
- return Ok(SPOS_MAX);
+ match s {
+ "POS_MIN" => return Ok(POS_MIN),
+ "POS_MAX" => return Ok(POS_MAX),
+ "SPOS_MAX" => return Ok(SPOS_MAX),
+ _ => (),
}
let mut fields = s.split(':');
--
2.47.0
next reply other threads:[~2024-10-27 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-27 14:21 Integral [this message]
2024-11-08 13:58 ` [PATCH] bcachefs-tools: replace multiple if with match to improve readability Integral
2024-11-27 11:18 ` Integral
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241027142127.110704-1-integral@archlinuxcn.org \
--to=integral@archlinuxcn.org \
--cc=kent.overstreet@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=lihongbo22@huawei.com \
--cc=linux-bcachefs@vger.kernel.org \
--cc=mmpgouride@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox