ligen_ir/macro_attributes/attributes/attribute/
named.rs

1use std::fmt::{Display, Formatter};
2
3use crate::prelude::*;
4use crate::{Path, Literal};
5
6/// Attribute enumeration.
7#[derive(Default, Debug, PartialEq, Clone, Serialize, Deserialize)]
8pub struct Named {
9    /// Path of the attribute.
10    pub path: Path,
11    /// Literal of the attribute.
12    // TODO: This can be any expression.
13    pub literal: Literal,
14}
15
16impl Named {
17    /// Creates a new named attribute.
18    pub fn new<I: Into<Path>, L: Into<Literal>>(path: I, literal: L) -> Self {
19        let path = path.into();
20        let literal = literal.into();
21        Self { path, literal }
22    }
23}
24
25impl Display for Named {
26    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
27        write!(f, "{} = {}", self.path, self.literal)
28    }
29}