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

impl<'a> TildeAble for Args<'a> {
    fn len(&self) -> usize {
        self.left_count()
    }

    fn into_tildekind_char(&self) -> Option<&dyn TildeKindChar> {
        match self.pop() {
            Some(a) => a.into_tildekind_char(),
            None => None,
        }
    }

    fn into_tildekind_float(&self) -> Option<&dyn TildeKindFloat> {
        match self.pop() {
            Some(a) => a.into_tildekind_float(),
            None => None,
        }
    }

    fn into_tildekind_digit(&self) -> Option<&dyn TildeKindDigit> {
        match self.pop() {
            Some(a) => a.into_tildekind_digit(),
            None => None,
        }
    }

    fn into_tildekind_va(&self) -> Option<&dyn TildeKindVa> {
        match self.pop() {
            Some(a) => a.into_tildekind_va(),
            None => None,
        }
    }

    fn into_tildekind_star(&self) -> Option<&dyn TildeKindStar> {
        Some(self)
    }

    fn into_tildekind_loop(&self) -> Option<&dyn TildeKindLoop> {
        Some(self)
    }

    fn into_tildekind_loopend(&self) -> Option<&dyn TildeKindLoopEnd> {
        None
    }

    fn into_tildekind_cond(&self) -> Option<&dyn TildeKindCond> {
        Some(self)
    }

    fn into_tildekind_text(&self) -> Option<&dyn TildeKindText> {
        None
    }

    fn into_tildekind_vectilde(&self) -> Option<&dyn TildeKindVecTilde> {
        Some(self)
    }

    fn into_tildekind_standard(&self) -> Option<&dyn TildeKindStandard> {
        match self.pop() {
            Some(a) => a.into_tildekind_standard(),
            None => None,
        }
    }

    fn into_tildekind_tildes(&self) -> Option<&dyn TildeKindTildes> {
        None
    }

    fn into_tildekind_radix(&self) -> Option<&dyn TildeKindRadix> {
        match self.pop() {
            Some(a) => a.into_tildekind_radix(),
            None => None,
        }
    }
}

/// impl mamually
impl TildeAble for Option<&dyn TildeAble> {
    fn len(&self) -> usize {
        match self {
            Some(_) => 1,
            None => 0,
        }
    }

    fn into_tildekind_cond(&self) -> Option<&dyn TildeKindCond> {
        Some(self)
    }
}

impl TildeAble for Vec<&dyn TildeAble> {
    fn len(&self) -> usize {
        self.len()
    }

    fn into_tildekind_va(&self) -> Option<&dyn TildeKindVa> {
        Some(self)
    }

    fn into_tildekind_loop(&self) -> Option<&dyn TildeKindLoop> {
        Some(self)
    }
}