Skip to content

Commit d5ecd7e

Browse files
authored
Merge pull request #283 from cakebaker/use_let_else_instead_of_match
bin/util-linux.rs: use `let`/`else` instead of `match`
2 parents c8a5770 + 41aace5 commit d5ecd7e

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/bin/util-linux.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ fn main() {
8585
process::exit(1);
8686
}
8787

88-
let util = match util_os.to_str() {
89-
Some(util) => util,
90-
None => not_found(&util_os),
88+
let Some(util) = util_os.to_str() else {
89+
not_found(&util_os)
9190
};
9291

9392
if util == "completion" {
@@ -106,9 +105,8 @@ fn main() {
106105
if util == "--help" || util == "-h" {
107106
// see if they want help on a specific util
108107
if let Some(util_os) = args.next() {
109-
let util = match util_os.to_str() {
110-
Some(util) => util,
111-
None => not_found(&util_os),
108+
let Some(util) = util_os.to_str() else {
109+
not_found(&util_os)
112110
};
113111

114112
match utils.get(util) {

0 commit comments

Comments
 (0)