1use super::*;
2
3#[derive(Debug, Clone)]
5pub enum Item<'src> {
6 Alias(Alias<'src, Name<'src>>),
7 Assignment(Assignment<'src>),
8 Comment(&'src str),
9 Import {
10 absolute: Option<PathBuf>,
11 optional: bool,
12 path: Token<'src>,
13 relative: StringLiteral<'src>,
14 },
15 Module {
16 attributes: BTreeSet<Attribute<'src>>,
17 absolute: Option<PathBuf>,
18 doc: Option<&'src str>,
19 name: Name<'src>,
20 optional: bool,
21 relative: Option<StringLiteral<'src>>,
22 },
23 Recipe(UnresolvedRecipe<'src>),
24 Set(Set<'src>),
25 Unexport {
26 name: Name<'src>,
27 },
28}
29
30impl<'src> Display for Item<'src> {
31 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
32 match self {
33 Self::Alias(alias) => write!(f, "{alias}"),
34 Self::Assignment(assignment) => write!(f, "{assignment}"),
35 Self::Comment(comment) => write!(f, "{comment}"),
36 Self::Import {
37 relative, optional, ..
38 } => {
39 write!(f, "import")?;
40
41 if *optional {
42 write!(f, "?")?;
43 }
44
45 write!(f, " {relative}")
46 }
47 Self::Module {
48 name,
49 relative,
50 optional,
51 ..
52 } => {
53 write!(f, "mod")?;
54
55 if *optional {
56 write!(f, "?")?;
57 }
58
59 write!(f, " {name}")?;
60
61 if let Some(path) = relative {
62 write!(f, " {path}")?;
63 }
64
65 Ok(())
66 }
67 Self::Recipe(recipe) => write!(f, "{}", recipe.color_display(Color::never())),
68 Self::Set(set) => write!(f, "{set}"),
69 Self::Unexport { name } => write!(f, "unexport {name}"),
70 }
71 }
72}