microcad_lang/syntax/statement/
assignment_statement.rs1use crate::{rc::*, src_ref::*, syntax::*};
7
8#[derive(Clone)]
10pub struct AssignmentStatement {
11 pub attribute_list: AttributeList,
13 pub assignment: Rc<Assignment>,
15 pub src_ref: SrcRef,
17}
18
19impl SrcReferrer for AssignmentStatement {
20 fn src_ref(&self) -> SrcRef {
21 self.src_ref.clone()
22 }
23}
24
25impl TreeDisplay for AssignmentStatement {
26 fn tree_print(&self, f: &mut std::fmt::Formatter, depth: TreeState) -> std::fmt::Result {
27 writeln!(f, "{:depth$}Assignment {}", "", self.assignment)
28 }
29}
30
31impl std::fmt::Display for AssignmentStatement {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 if !self.attribute_list.is_empty() {
34 write!(f, "{} ", self.attribute_list)?;
35 }
36 write!(f, "{};", self.assignment)
37 }
38}
39
40impl std::fmt::Debug for AssignmentStatement {
41 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 if !self.attribute_list.is_empty() {
43 write!(f, "{:?} ", self.attribute_list)?;
44 }
45 write!(f, "{:?};", self.assignment)
46 }
47}