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
// 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 mode: u16 = match mode_match {
Some(m) => {
let res: Option<u16> = u16::from_str_radix(&m, 8).ok();
if res.is_some() {
res.unwrap()
} else {
crash!(1, "no mode given");
match res {
Some(r) => r,
_ => crash!(1, "no mode given")
}
} else {
0o755 as u16
},
_ => 0o755 as u16
};
let dirs = matches.free;

View file

@ -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);
}