just/src/attribute.rs

38 lines
638 B
Rust
Raw Normal View History

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 {
2023-11-16 15:51:34 -08:00
Confirm,
Linux,
Macos,
2022-11-02 23:37:35 -07:00
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");
}
}