mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-04 15:07:47 +00:00
refactor/polish ~ fix cargo clippy
complaints (unnecessary_unwrap)
This commit is contained in:
parent
7cc3571657
commit
2ef9c9a28e
2 changed files with 13 additions and 14 deletions
|
@ -55,16 +55,15 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
// Translate a ~str in octal form to u16, default to 755
|
||||
// Not tested on Windows
|
||||
let mode_match = matches.opts_str(&["mode".to_owned()]);
|
||||
let mode: u16 = if mode_match.is_some() {
|
||||
let m = mode_match.unwrap();
|
||||
let res: Option<u16> = u16::from_str_radix(&m, 8).ok();
|
||||
if res.is_some() {
|
||||
res.unwrap()
|
||||
} else {
|
||||
crash!(1, "no mode given");
|
||||
}
|
||||
} else {
|
||||
0o755 as u16
|
||||
let mode: u16 = match mode_match {
|
||||
Some(m) => {
|
||||
let res: Option<u16> = u16::from_str_radix(&m, 8).ok();
|
||||
match res {
|
||||
Some(r) => r,
|
||||
_ => crash!(1, "no mode given")
|
||||
}
|
||||
},
|
||||
_ => 0o755 as u16
|
||||
};
|
||||
|
||||
let dirs = matches.free;
|
||||
|
|
|
@ -95,10 +95,10 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
|
|||
Some(sep) => {
|
||||
options.separator = sep;
|
||||
let next = chiter.next();
|
||||
if next.is_some() {
|
||||
if let Some(n) = next {
|
||||
show_error!(
|
||||
"unexpected character ('{}')",
|
||||
next.unwrap()
|
||||
n
|
||||
);
|
||||
return Err(1);
|
||||
}
|
||||
|
@ -112,10 +112,10 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
|
|||
Some(term) => {
|
||||
options.terminator = Some(term);
|
||||
let next = chiter.next();
|
||||
if next.is_some() {
|
||||
if let Some(n) = next {
|
||||
show_error!(
|
||||
"unexpected character ('{}')",
|
||||
next.unwrap()
|
||||
n
|
||||
);
|
||||
return Err(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue