microcad_lang/syntax/function/
function_definition.rs1use crate::{src_ref::*, syntax::*};
7
8#[derive(Debug, Clone)]
10pub struct FunctionDefinition {
11 pub visibility: Visibility,
13 pub id: Identifier,
15 pub signature: FunctionSignature,
17 pub body: Body,
19 pub src_ref: SrcRef,
21}
22
23impl SrcReferrer for FunctionDefinition {
24 fn src_ref(&self) -> SrcRef {
25 self.src_ref.clone()
26 }
27}
28
29impl TreeDisplay for FunctionDefinition {
30 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
31 writeln!(f, "{:depth$}FunctionDefinition '{}':", "", self.id)?;
32 depth.indent();
33 writeln!(f, "{:depth$}Signature:", "")?;
34 self.signature.tree_print(f, depth)?;
35 writeln!(f, "{:depth$}Body:", "")?;
36 self.body.tree_print(f, depth)
37 }
38}