pub(crate) fn parse_command<'a, 'b, I: Iterator<Item = &'a String>, E>(
    args: &mut Peekable<I>,
    commands: &Vec<Command<'b, E>>,
) -> ValueResult<usize> {
    let idx = match args.next() {
        None => return Err(ValueError::MissingCommand),
        Some(command_arg) => match commands
            .iter()
            .position(|command| command.name == *command_arg)
        {
            None => return Err(ValueError::UnknownCommand(command_arg.to_owned())),
            Some(idx) => idx,
        },
    };
    Ok(idx)
}
/// Look up by name the command indicated by the first element of the given
/// range of program parameters. If locating a matching command fails, an error
/// will be returned instead. Otherwise, the index of the command in the given
/// list of commands is returned.
Look up by name the command indicated by the first element of the given
range of program parameters. If locating a matching command fails, an error
will be returned instead. Otherwise, the index of the command in the given
list of commands is returned.
Look up by name the command indicated by the first element of the given range of program parameters . If locating a matching command fails an error will be returned instead . Otherwise the index of the command in the given list of commands is returned .
pub(crate) fn parse_command<'a, 'b, I: Iterator<Item = &'a String>, E>(
    args: &mut Peekable<I>,
    commands: &Vec<Command<'b, E>>,
) -> ValueResult<usize> {
    let idx = match args.next() {
        None => return Err(ValueError::MissingCommand),
        Some(command_arg) => match commands
            .iter()
            .position(|command| command.name == *command_arg)
        {
            None => return Err(ValueError::UnknownCommand(command_arg.to_owned())),
            Some(idx) => idx,
        },
    };
    Ok(idx)
}
pub ( crate ) fn parse_command < ' a , ' b , I : Iterator < Item = & ' a String > , E > ( args : & mut Peekable < I > , commands : & Vec < Command < ' b , E > > , ) -> ValueResult < usize > { let idx = match args . next ( ) { None => return Err ( ValueError :: MissingCommand ) , Some ( command_arg ) => match commands . iter ( ) . position ( | command | command . name == * command_arg ) { None => return Err ( ValueError :: UnknownCommand ( command_arg . to_owned ( ) ) ) , Some ( idx ) => idx , } , } ; Ok ( idx ) }
Look up by name the command indicated by the first element of the given
range of program parameters.
Look up by name the command indicated by the first element of the given range of program parameters .
args
&mut Peekable<I>
commands
&Vec<Command<'b, E>>
args
&mut Peekable<I>
commands
&Vec<Command<'b, E>>