just/src/keyword.rs
2024-01-12 20:38:23 +00:00

44 lines
723 B
Rust

use super::*;
#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
#[strum(serialize_all = "kebab_case")]
pub(crate) enum Keyword {
Alias,
AllowDuplicateRecipes,
DotenvFilename,
DotenvLoad,
DotenvPath,
Else,
Export,
Fallback,
False,
If,
IgnoreComments,
Import,
Mod,
PositionalArguments,
Quiet,
Set,
Shell,
Tempdir,
True,
WindowsPowershell,
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
}
}