pub trait Choice:
Sized
+ Clone
+ 'static {
// Required methods
fn value(&self) -> &str;
fn title(&self) -> &str;
}Expand description
A trait for defining choices in a choice set setting.
The trait has already been implemented for String, &str, and tuples of (&str, &str).
You can implement this trait for your own types to use them in a ChoiceSetSetting
(as long as their value don’t collide with each other):
#[derive(Debug, Clone)]
enum TextSize {
Small,
Medium,
Large
}
impl Choice for TextSize {
fn value(&self) -> &str {
match self {
TextSize::Small => "small",
TextSize::Medium => "medium",
TextSize::Large => "large",
}
}
fn title(&self) -> &str {
match self {
TextSize::Small => "Small",
TextSize::Medium => "Medium",
TextSize::Large => "Large",
}
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".