es_fluent/traits/
fluent_choice.rs

1/// This trait is used to convert an enum into a string that can be used as a
2/// Fluent choice.
3///
4/// # Example
5///
6/// ```rs
7/// use es_fluent::EsFluentChoice;
8///
9/// enum MyEnum {
10///     Variant1,
11///     Variant2,
12/// }
13///
14/// impl EsFluentChoice for MyEnum {
15///     fn as_fluent_choice(&self) -> &'static str {
16///         match self {
17///             MyEnum::Variant1 => "variant1",
18///             MyEnum::Variant2 => "variant2",
19///         }
20///     }
21/// }
22///
23/// let my_enum = MyEnum::Variant1;
24/// assert_eq!(my_enum.as_fluent_choice(), "variant1");
25/// ```
26pub trait EsFluentChoice {
27    fn as_fluent_choice(&self) -> &'static str;
28}