getopt: remove skip logic
The 'skip' variable was set to indicate that the "rest of the args" is to be copied into the 'rest' vec. We can do this directly and avoid the 'if' case in the loop altogether. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
99da3a073d
commit
2482c095b1
@ -67,18 +67,10 @@ pub fn parse_arguments(
|
||||
|
||||
let mut pos = 0;
|
||||
|
||||
let mut skip = false;
|
||||
|
||||
while pos < args.len() {
|
||||
if skip {
|
||||
rest.push(args[pos].clone());
|
||||
pos += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
match parse_argument(&args[pos]) {
|
||||
RawArgument::Separator => {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
RawArgument::Option { name, value } => {
|
||||
match value {
|
||||
@ -142,6 +134,8 @@ pub fn parse_arguments(
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
rest.extend_from_slice(&args[pos..]);
|
||||
|
||||
for i in 0..arg_param.len() {
|
||||
if rest.len() > i {
|
||||
data.push((arg_param[i].to_string(), rest[i].clone()));
|
||||
|
Loading…
Reference in New Issue
Block a user