pub trait ValueEnum: Sized + 'static {
const VARIANTS: &'static [Self];
const POSSIBLE_VALUES: &'static [&'static str];
// Required methods
fn value_name(&self) -> &'static str;
fn from_value(value: &str) -> Option<Self>;
}Expand description
An enum whose variants are the accepted values of an argument.
Usually implemented with #[derive(ValueEnum)]. Fields of a
ValueEnum type marked with #[arg(value_enum)] are parsed with from_value
and list their POSSIBLE_VALUES in the generated help.
Required Associated Constants§
Sourceconst POSSIBLE_VALUES: &'static [&'static str]
const POSSIBLE_VALUES: &'static [&'static str]
The name of every variant, in declaration order, as accepted on the command line and shown in the generated help. Aliases are not included.
Required Methods§
Sourcefn value_name(&self) -> &'static str
fn value_name(&self) -> &'static str
Returns the name of this variant, as listed in POSSIBLE_VALUES.
Sourcefn from_value(value: &str) -> Option<Self>
fn from_value(value: &str) -> Option<Self>
Returns the variant whose name or alias is exactly value, if any.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".