bcachefs-tools: replace multiple if with match to improve readability
PATCH 1/1 bcachefs-tools: replace multiple if with match to improve readability
Replace multiple if expressions with match in Rust code to improve readability.
Signed-off-by Integral <[email protected]>
--- bch_bindgen/src/lib.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
bch_bindgen/src/lib.rs +5 -10
@@ -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
Hi, Kent
Give you a friendly ping :)
Hi, Kent
Give you a gentle ping :)