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
use atom::Atom;
use container::{ Container, ContainerCompound };
use ion::Ion;
use molecule::Molecule;
use reaction::{ ElemReaction, ReactionSide, ReactionCompound };
use trait_element::Element;
use trait_properties::Properties;

use std::fmt::{ Display, Formatter, Result };


macro_rules! fmt {
    ($x:tt) => (
        impl Display for $x {
            fn fmt(&self, formatter: &mut Formatter) -> Result {
                write!(formatter, "{}", self.stringify())
            }
        }
    )
}


macro_rules! fmt_lifetime {
    ($x:tt) => (
        impl<'lifetime> Display for $x<'lifetime> {
            fn fmt(&self, formatter: &mut Formatter) -> Result {
                write!(formatter, "{}", self.stringify())
            }
        }
    )
}


macro_rules! fmt_type {
    ($x:tt) => (
        impl<E: Element> Display for $x<E> {
            fn fmt(&self, formatter: &mut Formatter) -> Result {
                write!(formatter, "{}", self.stringify())
            }
        }
    )
}


macro_rules! fmt_lifetime_type {
    ($x:tt) => (
        impl<'lifetime, E: Element> Display for $x<'lifetime, E> {
            fn fmt(&self, formatter: &mut Formatter) -> Result {
                write!(formatter, "{}", self.stringify())
            }
        }
    )
}


fmt!(Atom);
fmt!(Ion);
fmt!(Molecule);
fmt_type!(Container);
fmt_type!(ContainerCompound);
fmt_type!(ElemReaction);
fmt_type!(ReactionCompound);
fmt_type!(ReactionSide);