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

    macro_rules! simple_enum {
        ($e:ident => $($v:ident),+) => { ... };
    }

Convenience macro generated a simple enum with variants to be used as a type when parsing arguments. This enum also provides a `variants()` function which can be used to retrieve a `Vec<&'static str>` of the variant names.

NOTE: This macro automatically implements std::str::FromStr and std::fmt::Display

# Examples

    simple_enum!{Foo => Bar, Baz, Qux}
    // Foo enum can now be used via Foo::Bar, or Foo::Baz, etc
    // and implements std::str::FromStr to use with the value_t! macros
    fn main() {
        let enum_vals = ["Bar", "Baz", "Qux"];
        let m = App::new("app")
                    .arg(Arg::from_usage("<foo> 'the foo'")
                        .possible_values(&enum_vals))
                    .get_matches();
        let f = value_t_or_exit!(m.value_of("foo"), Foo);

        // Use f like any other Foo variant...
    }

# 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`)