fn parse_arg<T: FromStr>(
    arg_matches: &ArgMatches,
    arg: &str,
    default: impl FnOnce() -> T,
) -> Result<T, ConfigError> {
    match arg_matches.value_of(arg) {
        Some(value) => match value.parse() {
            Ok(parsed) => Ok(parsed),
            Err(_) => {
                // log::error!("Failed to parse the '{arg}' argument. Incorrect value was given: '{value}'");
                // std::process::exit(1);
                return Err(ConfigError::BadArgument(format!(
                    "Failed to parse the '{arg}' argument. Incorrect value was given: '{value}'"
                )));
            }
        },
        None => {
            Ok(default())
            // default
        }
    }
}
/// Attempts to parse a given argument into the assigned type. Exists the program on failure.
// fn parse_arg<T: FromStr>(arg_matches: ArgMatches, arg: &str, default: fn() -> T, on_error: OnParseError<T, fn() -> T>) -> T {
// fn parse_arg<T: FromStr>(arg_matches: ArgMatches, arg: &str, default: fn() -> T) -> T {
// fn parse_arg<T: FromStr>(arg_matches: ArgMatches, arg: &str, default: impl Fn() -> T) -> T {
// fn parse_arg<T: FromStr>(arg_matches: &ArgMatches, arg: &str, default: T) -> T {
Attempts to parse a given argument into the assigned type. Exists the program on failure.
Attempts to parse a given argument into the assigned type . Exists the program on failure .
fn parse_arg<T: FromStr>(
    arg_matches: &ArgMatches,
    arg: &str,
    default: impl FnOnce() -> T,
) -> Result<T, ConfigError> {
    match arg_matches.value_of(arg) {
        Some(value) => match value.parse() {
            Ok(parsed) => Ok(parsed),
            Err(_) => {
                // log::error!("Failed to parse the '{arg}' argument. Incorrect value was given: '{value}'");
                // std::process::exit(1);
                return Err(ConfigError::BadArgument(format!(
                    "Failed to parse the '{arg}' argument. Incorrect value was given: '{value}'"
                )));
            }
        },
        None => {
            Ok(default())
            // default
        }
    }
}
fn parse_arg < T : FromStr > ( arg_matches : & ArgMatches , arg : & str , default : impl FnOnce ( ) -> T , ) -> Result < T , ConfigError > { match arg_matches . value_of ( arg ) { Some ( value ) => match value . parse ( ) { Ok ( parsed ) => Ok ( parsed ) , Err ( _ ) => { // log::error!("Failed to parse the '{arg}' argument. Incorrect value was given: '{value}'"); // std::process::exit(1); return Err ( ConfigError :: BadArgument ( format ! ( " " ) ) ) ; } } , None => { Ok ( default ( ) ) // default } } }
Attempts to parse a given argument into the assigned type.
Attempts to parse a given argument into the assigned type .
arg_matches
&ArgMatches
arg
&str
default
impl FnOnce() -> T
arg_matches
&ArgMatches
arg
&str
default
impl FnOnce() -> T