# clap::value_t_or_exit! [−] [src]

    macro_rules! value_t_or_exit {
        ($m:ident.value_of($v:expr), $t:ty) => { ... };
        ($m:ident.values_of($v:expr), $t:ty) => { ... };
    }

Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr` This macro returns a `T` or `Vec<T>` or exits with a usage string upon failure. This removes some of the boiler plate to handle failures from value_t! above.

You can use it to get a single value `T`, or a `Vec<T>` with the `values_of()`

NOTE: This should only be used on required arguments, as it can be confusing to the user why they are getting error messages when it appears they're entering all required arguments.

NOTE: Be cautious, as since this a macro invocation it's not exactly like standard syntax.

# Examples single value

    let matches = App::new("myapp")
                  .arg_from_usage("[length] 'Set the length to use as a pos whole num, i.e. 20'")
                  .get_matches();
    let len = value_t_or_exit!(matches.value_of("length"), u32);

    println!("{} + 2: {}", len, len + 2);

# Examples multiple values

    let matches = App::new("myapp")
                      .arg_from_usage("[seq]... 'A sequence of pos whole nums, i.e. 20 45'")
                      .get_matches();
    for v in value_t_or_exit!(matches.values_of("seq"), u32) {
        println!("{} + 2: {}", v, v + 2);
    }

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)