tailwind_ast/ast/
display.rs

1use super::*;
2
3impl<'a> Display for AstGroup<'a> {
4    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
5        let children: Vec<_> = self.children.iter().map(|s| s.to_string()).collect();
6        write!(f, "{}({})", self.head, children.join(" "))
7    }
8}
9
10impl<'a> Display for AstGroupItem<'a> {
11    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
12        match self {
13            Self::Grouped(g) => Display::fmt(g, f),
14            Self::Styled(g) => Display::fmt(g, f),
15        }
16    }
17}
18
19impl<'a> Display for AstStyle<'a> {
20    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
21        for v in &self.variants {
22            write!(f, "{}", v)?
23        }
24        if self.negative {
25            write!(f, "-")?
26        }
27        write!(f, "{}", self.elements.join("-"))?;
28        match self.arbitrary {
29            None => {}
30            Some(s) => write!(f, "-[{}]", s)?,
31        }
32        Ok(())
33    }
34}
35
36impl<'a> Display for ASTVariant<'a> {
37    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
38        if self.not {
39            write!(f, "not-")?
40        }
41        write!(f, "{}", self.names.join("-"))?;
42        match self.pseudo {
43            true => write!(f, "::"),
44            false => write!(f, ":"),
45        }
46    }
47}