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 (loop/match => while let)

This commit is contained in:
Roy Ivy III 2019-12-26 10:53:12 -06:00
parent 98039f176d
commit fd8e5acd57
2 changed files with 98 additions and 108 deletions

View file

@ -90,17 +90,10 @@ fn get_inprefix(str_in: &str, field_type: &FieldType) -> InPrefix {
let mut topchar = str_it.next(); let mut topchar = str_it.next();
// skip spaces and ensure topchar is the first non-space char // skip spaces and ensure topchar is the first non-space char
// (or None if none exists) // (or None if none exists)
loop { while let Some(' ') = topchar {
match topchar {
Some(' ') => {
ret.offset += 1; ret.offset += 1;
topchar = str_it.next(); topchar = str_it.next();
} }
_ => {
break;
}
}
}
// parse sign // parse sign
match topchar { match topchar {
Some('+') => { Some('+') => {

View file

@ -41,9 +41,8 @@ fn escape_sequences(s: &str) -> String {
fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, i32> { fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, i32> {
let mut seq_args = vec![]; let mut seq_args = vec![];
let mut iter = args.into_iter().skip(1); let mut iter = args.into_iter().skip(1);
loop { while let Some(arg) = iter.next() {
match iter.next() { match &arg[..] {
Some(arg) => match &arg[..] {
"--help" | "-h" => { "--help" | "-h" => {
print_help(); print_help();
return Err(0); return Err(0);
@ -137,10 +136,8 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
seq_args.push(arg); seq_args.push(arg);
} }
} }
}, };
None => break, };
}
}
Ok(seq_args) Ok(seq_args)
} }