public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bcachefs-tools: replace multiple if with match to improve readability
@ 2024-10-27 14:21 Integral
  2024-11-08 13:58 ` Integral
  2024-11-27 11:18 ` Integral
  0 siblings, 2 replies; 3+ messages in thread
From: Integral @ 2024-10-27 14:21 UTC (permalink / raw)
  To: kent.overstreet, kent.overstreet, lihongbo22
  Cc: mmpgouride, linux-bcachefs, integral

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-27 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-27 14:21 [PATCH] bcachefs-tools: replace multiple if with match to improve readability Integral
2024-11-08 13:58 ` Integral
2024-11-27 11:18 ` Integral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox