Skip to content

bin/util-linux.rs: use let/else instead of match #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/bin/util-linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ fn main() {
process::exit(1);
}

let util = match util_os.to_str() {
Some(util) => util,
None => not_found(&util_os),
let Some(util) = util_os.to_str() else {
not_found(&util_os)
};

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

match utils.get(util) {
Expand Down