pub trait MatchArg:
Sized
+ Copy
+ 'static {
const CHOICES: &'static [&'static str];
// Required methods
fn from_choice(choice: &str) -> Option<Self>;
fn to_choice(self) -> &'static str;
}Expand description
Trait for enum types that support match.arg-style string conversion.
Implementors provide a fixed set of choice strings and bidirectional conversion between enum variants and their string representations.
Use #[derive(MatchArg)] to auto-generate this implementation.
Required Associated Constants§
Required Methods§
Sourcefn from_choice(choice: &str) -> Option<Self>
fn from_choice(choice: &str) -> Option<Self>
Convert a choice string to the corresponding enum variant.
Returns None if the string doesn’t match any choice exactly.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.