fn parse_next_named_flag<'a, 'b, I: Iterator<Item = &'b String>>(
    specs: &'a Specs,
    args: &mut Peekable<I>,
) -> ValueResult<Option<ParsedNamedFlag>> {
    let flag: &'b String = match args.peek() {
        Some(p) => {
            if p.starts_with('-') {
                p
            } else {
                return Ok(None);
            }
        }
        None => return Ok(None),
    };
    args.next();

    let mut spec = NamedFlagSpec::new(specs, flag)?;

    // Search for the value in the next parameter, if this flag is not a
    // boolean flag. For boolean flags, because explicit values are optional,
    // it is ambiguous whether the next arg is our value or a positional flag.
    if !spec.spec.is_boolean() {
        let next_arg_is_value = args.peek().map_or(false, |v| !v.starts_with('-'));
        if next_arg_is_value && spec.value.is_none() {
            spec.value = Some(args.next().unwrap().clone());
        }
    }

    Ok(Some(ParsedNamedFlag {
        name: spec.spec.get_name().to_owned(),
        value: new_named_flag_value(&spec.spec, spec.value)?,
    }))
}
/// Parse the next named flag from the given iterator over this program's
/// command-line arguments. If there are no more named flags, returns None. If
/// a flag was found but some error occured in parsing its name or value, then
/// an error is returned.
Parse the next named flag from the given iterator over this program's
command-line arguments. If there are no more named flags, returns None. If
a flag was found but some error occured in parsing its name or value, then
an error is returned.
Parse the next named flag from the given iterator over this program ' s command - line arguments . If there are no more named flags returns None . If a flag was found but some error occured in parsing its name or value then an error is returned .
fn parse_next_named_flag<'a, 'b, I: Iterator<Item = &'b String>>(
    specs: &'a Specs,
    args: &mut Peekable<I>,
) -> ValueResult<Option<ParsedNamedFlag>> {
    let flag: &'b String = match args.peek() {
        Some(p) => {
            if p.starts_with('-') {
                p
            } else {
                return Ok(None);
            }
        }
        None => return Ok(None),
    };
    args.next();
    let mut spec = NamedFlagSpec::new(specs, flag)?;
    // Search for the value in the next parameter, if this flag is not a
    // boolean flag. For boolean flags, because explicit values are optional,
    // it is ambiguous whether the next arg is our value or a positional flag.
    if !spec.spec.is_boolean() {
        let next_arg_is_value = args.peek().map_or(false, |v| !v.starts_with('-'));
        if next_arg_is_value && spec.value.is_none() {
            spec.value = Some(args.next().unwrap().clone());
        }
    }
    Ok(Some(ParsedNamedFlag {
        name: spec.spec.get_name().to_owned(),
        value: new_named_flag_value(&spec.spec, spec.value)?,
    }))
}
fn parse_next_named_flag < ' a , ' b , I : Iterator < Item = & ' b String > > ( specs : & ' a Specs , args : & mut Peekable < I > , ) -> ValueResult < Option < ParsedNamedFlag > > { let flag : & ' b String = match args . peek ( ) { Some ( p ) => { if p . starts_with ( '-' ) { p } else { return Ok ( None ) ; } } None => return Ok ( None ) , } ; args . next ( ) ; let mut spec = NamedFlagSpec :: new ( specs , flag ) ? ; // Search for the value in the next parameter, if this flag is not a // boolean flag. For boolean flags, because explicit values are optional, // it is ambiguous whether the next arg is our value or a positional flag. if ! spec . spec . is_boolean ( ) { let next_arg_is_value = args . peek ( ) . map_or ( false , | v | ! v . starts_with ( '-' ) ) ; if next_arg_is_value && spec . value . is_none ( ) { spec . value = Some ( args . next ( ) . unwrap ( ) . clone ( ) ) ; } } Ok ( Some ( ParsedNamedFlag { name : spec . spec . get_name ( ) . to_owned ( ) , value : new_named_flag_value ( & spec . spec , spec . value ) ? , } ) ) }
Parse the next named flag from the given iterator over this program's
command-line arguments.
Parse the next named flag from the given iterator over this program ' s command - line arguments .
specs
&'a Specs
args
&mut Peekable<I>
specs
&'a Specs
args
&mut Peekable<I>