1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#[derive(PartialEq, Debug, Copy, Clone)] pub enum When { Auto, Never, Always, } impl std::str::FromStr for When { type Err = String; fn from_str(text: &str) -> Result<Self, Self::Err> { Ok(match text { "auto" => When::Auto, "never" => When::Never, "always" => When::Always, _ => return Err(text.to_string()), }) } }