1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use super::*;

impl Debug for LetBindNode {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        let w = &mut f.debug_struct("VariableDeclaration");
        w.field("pattern", &self.pattern);
        if let Some(type_hint) = &self.type_hint {
            w.field("type", type_hint);
        }
        if let Some(body) = &self.body {
            w.field("body", body);
        }
        w.field("span", &self.span);
        w.finish()
    }
}

impl Debug for VariableDeclaration {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        let w = &mut f.debug_struct("VariableDeclaration");
        if let Some(type_hint) = &self.type_hint {
            w.field("type", type_hint);
        }
        if let Some(body) = &self.body {
            w.field("body", body);
        }
        w.finish()
    }
}

#[cfg(feature = "pretty-print")]
impl PrettyPrint for LetBindNode {
    fn pretty(&self, theme: &PrettyProvider) -> PrettyTree {
        let mut terms = PrettySequence::new(3);
        terms += theme.keyword("let");
        terms += " ";
        terms += self.pattern.pretty(theme);
        if let Some(type_hint) = &self.type_hint {
            terms += ":";
            terms += " ";
            terms += type_hint.pretty(theme);
        }
        if let Some(body) = &self.body {
            terms += " ";
            terms += "=";
            terms += " ";
            terms += body.pretty(theme);
        }
        terms.into()
    }
}