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();
// skip spaces and ensure topchar is the first non-space char
// (or None if none exists)
loop {
match topchar {
Some(' ') => {
while let Some(' ') = topchar {
ret.offset += 1;
topchar = str_it.next();
}
_ => {
break;
}
}
}
// parse sign
match topchar {
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> {
let mut seq_args = vec![];
let mut iter = args.into_iter().skip(1);
loop {
match iter.next() {
Some(arg) => match &arg[..] {
while let Some(arg) = iter.next() {
match &arg[..] {
"--help" | "-h" => {
print_help();
return Err(0);
@ -137,10 +136,8 @@ fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<Stri
seq_args.push(arg);
}
}
},
None => break,
}
}
};
};
Ok(seq_args)
}