just/src/attribute.rs
2023-11-16 23:51:34 +00:00

38 lines
638 B
Rust

use super::*;
#[derive(
EnumString, PartialEq, Debug, Copy, Clone, Serialize, Ord, PartialOrd, Eq, IntoStaticStr,
)]
#[strum(serialize_all = "kebab-case")]
#[serde(rename_all = "kebab-case")]
pub(crate) enum Attribute {
Confirm,
Linux,
Macos,
NoCd,
NoExitMessage,
Private,
Unix,
Windows,
}
impl Attribute {
pub(crate) fn from_name(name: Name) -> Option<Attribute> {
name.lexeme().parse().ok()
}
pub(crate) fn to_str(self) -> &'static str {
self.into()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn to_str() {
assert_eq!(Attribute::NoExitMessage.to_str(), "no-exit-message");
}
}