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:
Wolfgang Bumiller 2018-12-28 13:59:44 +01:00
parent 99da3a073d
commit 2482c095b1

View File

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