logo
pub trait ArgEnum: Sized + Clone {
    fn value_variants<'a>() -> &'a [Self]Notable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8];
fn to_arg_value<'a>(&self) -> Option<ArgValue<'a>>; fn from_str(input: &str, case_insensitive: bool) -> Result<Self, String> { ... } }
Expand description

Parse arguments into enums.

When deriving Parser, a field whose type implements ArgEnum can have the attribute #[clap(arg_enum)]. In addition to parsing, help and error messages may report possible variants.

Example

#[derive(clap::Parser)]
struct Args {
   #[clap(arg_enum)]
   level: Level,
}

#[derive(clap::ArgEnum, Clone)]
enum Level {
   Debug,
   Info,
   Warning,
   Error,
}

Required methods

All possible argument values, in display order.

The canonical argument value.

The value is None for skipped variants.

Provided methods

Parse an argument into Self.

Implementors