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

impl MathOperator {
    pub fn new<S>(text: S) -> Self
    where
        S: ToString,
    {
        Self { operator: text.to_string() }
    }
}

impl MathSub {
    pub fn new(base: MathML, sub: MathML) -> Self {
        Self { base, sub }
    }
}

impl MathSup {
    pub fn new(base: MathML, sup: MathML) -> Self {
        Self { base, sup }
    }
}

impl MathSubSup {
    pub fn new(base: MathML, sub: MathML, sup: MathML) -> Self {
        Self { base, sub, sup }
    }
}

impl MathML {
    pub fn operation<S>(text: S) -> Self
    where
        S: ToString,
    {
        MathOperator::new(text).into()
    }
}

impl From<MathOperator> for MathML {
    fn from(value: MathOperator) -> Self {
        MathML::Operator(Box::new(value))
    }
}

impl From<MathSub> for MathML {
    fn from(value: MathSub) -> Self {
        MathML::Sub(Box::new(value))
    }
}

impl From<MathSup> for MathML {
    fn from(value: MathSup) -> Self {
        MathML::Sup(Box::new(value))
    }
}

impl From<MathSubSup> for MathML {
    fn from(value: MathSubSup) -> Self {
        MathML::SubSup(Box::new(value))
    }
}