1
Fork 0
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:
Roy Ivy III 2019-12-29 00:23:03 -06:00
parent 7cc3571657
commit 2ef9c9a28e
2 changed files with 13 additions and 14 deletions

View file

@ -55,16 +55,15 @@ pub fn uumain(args: Vec<String>) -> i32 {
// Translate a ~str in octal form to u16, default to 755 // Translate a ~str in octal form to u16, default to 755
// Not tested on Windows // Not tested on Windows
let mode_match = matches.opts_str(&["mode".to_owned()]); let mode_match = matches.opts_str(&["mode".to_owned()]);
let mode: u16 = if mode_match.is_some() { let mode: u16 = match mode_match {
let m = mode_match.unwrap(); Some(m) => {
let res: Option<u16> = u16::from_str_radix(&m, 8).ok(); let res: Option<u16> = u16::from_str_radix(&m, 8).ok();
if res.is_some() { match res {
res.unwrap() Some(r) => r,
} else { _ => crash!(1, "no mode given")
crash!(1, "no mode given"); }
} },
} else { _ => 0o755 as u16
0o755 as u16
}; };
let dirs = matches.free; let dirs = matches.free;

View file

@ -95,10 +95,10 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
Some(sep) => { Some(sep) => {
options.separator = sep; options.separator = sep;
let next = chiter.next(); let next = chiter.next();
if next.is_some() { if let Some(n) = next {
show_error!( show_error!(
"unexpected character ('{}')", "unexpected character ('{}')",
next.unwrap() n
); );
return Err(1); return Err(1);
} }
@ -112,10 +112,10 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
Some(term) => { Some(term) => {
options.terminator = Some(term); options.terminator = Some(term);
let next = chiter.next(); let next = chiter.next();
if next.is_some() { if let Some(n) = next {
show_error!( show_error!(
"unexpected character ('{}')", "unexpected character ('{}')",
next.unwrap() n
); );
return Err(1); return Err(1);
} }