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::*;

// noinspection DuplicatedCode
impl PrettyPrint for GenericCallNode {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let mut terms = Vec::with_capacity(3);
        terms.push(allocator.text("⦓"));
        terms.push(allocator.join(&self.terms, ", "));
        terms.push(allocator.text("⦔"));
        allocator.concat(terms)
    }
}

impl PrettyPrint for GenericCallTerm {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let mut terms = Vec::with_capacity(3);
        if let Some(k) = &self.term.key {
            terms.push(allocator.generic(k.name.to_owned()));
            terms.push(allocator.text(": "));
        }
        terms.push(self.term.value.build(allocator));
        allocator.concat(terms)
    }
}

// noinspection DuplicatedCode
impl PrettyPrint for GenericArgumentNode {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let mut terms = Vec::with_capacity(3);
        terms.push(allocator.text("⦓"));
        terms.push(allocator.join(&self.terms, ", "));
        terms.push(allocator.text("⦔"));
        allocator.concat(terms)
    }
}

impl PrettyPrint for GenericArgumentTerm {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let mut terms = Vec::with_capacity(5);
        terms.push(allocator.generic(self.term.key.name.to_owned()));
        if let Some(k) = &self.term.value {
            terms.push(allocator.text(": "));
            terms.push(k.build(allocator));
        }
        if let Some(k) = &self.term.default {
            terms.push(allocator.text(" = "));
            terms.push(k.build(allocator));
        }
        allocator.concat(terms)
    }
}