Function crosvm_direct::crosvm::argument::set_arguments
source · [−]pub fn set_arguments<I, R, F>(
args: I,
arg_list: &[Argument],
f: F
) -> Result<(), Error> where
I: Iterator<Item = R>,
R: AsRef<str>,
F: FnMut(&str, Option<&str>) -> Result<(), Error>,
Expand description
Parses the given args
against the list of know arguments arg_list
and calls f
with each
present argument and value if required.
This function guarantees that only valid long argument names from arg_list
are sent to the
callback f
. It is also guaranteed that if an arg requires a value (i.e.
arg.value.is_some()
), the value will be Some
in the callbacks arguments. If the callback
returns Err
, this function will end parsing and return that Err
.
See the module level example for a usage example.