Merge pull request #283 from cakebaker/use_let_else_instead_of_match

bin/util-linux.rs: use `let`/`else` instead of `match`
This commit is contained in:
Sylvestre Ledru
2025-07-30 10:31:41 +02:00
committed by GitHub

View File

@@ -85,9 +85,8 @@ fn main() {
process::exit(1); process::exit(1);
} }
let util = match util_os.to_str() { let Some(util) = util_os.to_str() else {
Some(util) => util, not_found(&util_os)
None => not_found(&util_os),
}; };
if util == "completion" { if util == "completion" {
@@ -106,9 +105,8 @@ fn main() {
if util == "--help" || util == "-h" { if util == "--help" || util == "-h" {
// see if they want help on a specific util // see if they want help on a specific util
if let Some(util_os) = args.next() { if let Some(util_os) = args.next() {
let util = match util_os.to_str() { let Some(util) = util_os.to_str() else {
Some(util) => util, not_found(&util_os)
None => not_found(&util_os),
}; };
match utils.get(util) { match utils.get(util) {