rev: use "if let" instead of match
This commit is contained in:
@@ -24,8 +24,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||||||
let zero = matches.get_flag(options::ZERO);
|
let zero = matches.get_flag(options::ZERO);
|
||||||
|
|
||||||
let sep = if zero { b'\0' } else { b'\n' };
|
let sep = if zero { b'\0' } else { b'\n' };
|
||||||
match files {
|
|
||||||
Some(files) => {
|
if let Some(files) = files {
|
||||||
for path in files {
|
for path in files {
|
||||||
let Ok(file) = std::fs::File::open(path) else {
|
let Ok(file) = std::fs::File::open(path) else {
|
||||||
uucore::error::set_exit_code(1);
|
uucore::error::set_exit_code(1);
|
||||||
@@ -37,12 +37,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||||||
uucore::show_error!("cannot read {path}: {err}");
|
uucore::show_error!("cannot read {path}: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
None => {
|
|
||||||
let stdin = std::io::stdin().lock();
|
let stdin = std::io::stdin().lock();
|
||||||
let _ = rev_stream(stdin, sep);
|
let _ = rev_stream(stdin, sep);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user