microcad_lang/syntax/use/
use_statement.rs1use crate::{src_ref::*, syntax::*};
7
8#[derive(Clone, Debug)]
15pub struct UseStatement {
16 pub visibility: Visibility,
18 pub decl: UseDeclaration,
20 pub src_ref: SrcRef,
22}
23
24impl SrcReferrer for UseStatement {
25 fn src_ref(&self) -> SrcRef {
26 self.src_ref.clone()
27 }
28}
29
30impl std::fmt::Display for UseStatement {
31 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
32 match &self.visibility {
33 Visibility::Private => write!(f, "use ")?,
34 Visibility::Public => write!(f, "pub use ")?,
35 }
36 write!(f, "{}", self.decl)?;
37 Ok(())
38 }
39}
40
41impl TreeDisplay for UseStatement {
42 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
43 writeln!(f, "{:depth$}UseStatement", "")?;
44 depth.indent();
45 self.decl.tree_print(f, depth)
46 }
47}