just/src/keyword.rs

45 lines
750 B
Rust
Raw Normal View History

use super::*;
#[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,
AllowDuplicateVariables,
DotenvFilename,
DotenvLoad,
DotenvPath,
Else,
Export,
Fallback,
False,
If,
IgnoreComments,
Import,
2023-12-27 20:27:15 -08:00
Mod,
PositionalArguments,
Quiet,
Set,
Shell,
Tempdir,
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
}
}