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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use super::{ImplCount, ImplCounts, ImplKind, ItemCount};
use std::ops::{Add, AddAssign};

pub fn acc_sum<T: Add + AddAssign>(mut acc: T, new: T) -> T {
    acc += new;
    acc
}

impl Add for ItemCount {
    type Output = ItemCount;

    fn add(self, rhs: Self) -> Self::Output {
        ItemCount {
            modules: self.modules + rhs.modules,
            structs: self.structs + rhs.structs,
            unions: self.unions + rhs.unions,
            enums: self.enums + rhs.enums,
            functions: self.functions + rhs.functions,
            traits: self.traits + rhs.traits,
            constants: self.constants + rhs.constants,
            statics: self.statics + rhs.statics,
            type_alias: self.type_alias + rhs.type_alias,
            macros_decl: self.macros_decl + rhs.macros_decl,
            macros_func: self.macros_func + rhs.macros_func,
            macros_attr: self.macros_attr + rhs.macros_attr,
            macros_derv: self.macros_derv + rhs.macros_derv,
        }
    }
}

impl Add for ImplKind {
    type Output = ImplKind;

    fn add(self, rhs: Self) -> Self::Output {
        match (self, rhs) {
            (ImplKind::Inherent, ImplKind::Inherent) => ImplKind::Inherent,
            (ImplKind::Trait, ImplKind::Trait) => ImplKind::Trait,
            _ => ImplKind::Both,
        }
    }
}

impl AddAssign for ImplKind {
    fn add_assign(&mut self, rhs: Self) {
        *self = match (&self, rhs) {
            (ImplKind::Inherent, ImplKind::Inherent) => ImplKind::Inherent,
            (ImplKind::Trait, ImplKind::Trait) => ImplKind::Trait,
            _ => ImplKind::Both,
        };
    }
}

impl AddAssign for ImplCount {
    fn add_assign(&mut self, rhs: Self) {
        self.structs += rhs.structs;
        self.enums += rhs.enums;
        self.unions += rhs.unions;
        self.kind += rhs.kind;
        self.total += rhs.total;
    }
}

impl Add for ImplCount {
    type Output = ImplCount;

    fn add(self, rhs: Self) -> Self::Output {
        ImplCount {
            structs: self.structs + rhs.structs,
            enums: self.enums + rhs.enums,
            unions: self.unions + rhs.unions,
            kind: self.kind + rhs.kind,
            total: self.total + rhs.total,
        }
    }
}

impl AddAssign for ItemCount {
    fn add_assign(&mut self, rhs: Self) {
        self.modules += rhs.modules;
        self.structs += rhs.structs;
        self.unions += rhs.unions;
        self.enums += rhs.enums;
        self.functions += rhs.functions;
        self.traits += rhs.traits;
        self.constants += rhs.constants;
        self.statics += rhs.statics;
        self.type_alias += rhs.type_alias;
        self.macros_decl += rhs.macros_decl;
        self.macros_func += rhs.macros_func;
        self.macros_attr += rhs.macros_attr;
        self.macros_derv += rhs.macros_derv;
    }
}

impl Add for ImplCounts {
    type Output = ImplCounts;

    fn add(self, rhs: Self) -> Self::Output {
        ImplCounts {
            inherent: self.inherent + rhs.trait_,
            trait_: self.trait_ + rhs.trait_,
            total: self.total + rhs.total,
        }
    }
}

impl AddAssign for ImplCounts {
    fn add_assign(&mut self, rhs: Self) {
        self.inherent += rhs.trait_;
        self.trait_ += rhs.trait_;
        self.total += rhs.total;
    }
}