just/src/keyword.rs

36 lines
632 B
Rust
Raw Normal View History

use crate::common::*;
#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
#[strum(serialize_all = "kebab_case")]
pub(crate) enum Keyword {
Alias,
2022-02-14 18:37:06 -08:00
AllowDuplicateRecipes,
DotenvLoad,
Else,
Export,
False,
If,
PositionalArguments,
Set,
Shell,
True,
2022-01-18 11:02:15 -08:00
WindowsPowershell,
2022-05-31 13:01:59 -07:00
WindowsShell,
}
impl Keyword {
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Keyword> {
lexeme.parse().ok()
}
pub(crate) fn lexeme(self) -> &'static str {
self.into()
}
}
impl<'a> PartialEq<&'a str> for Keyword {
fn eq(&self, other: &&'a str) -> bool {
self.lexeme() == *other
}
}