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
//! Key alias.

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

/// Construct a new key type.
macro_rules! key {
    ($key:ident) => {
        #[json]
        #[derive(Clone, PartialOrd, Eq, PartialEq, Ord)]
        pub struct $key(String);

        impl $key {
            #[inline]
            #[must_use]
            pub fn new(string: &str) -> Self {
                Self {
                    0: string.to_string(),
                }
            }

            #[inline]
            #[must_use]
            pub fn str(&self) -> &str {
                &self.0
            }
        }

        impl Display for $key {
            #[inline]
            fn fmt(&self, fmt: &mut Formatter) -> Result {
                write!(fmt, "{}", self.0)
            }
        }
    };
}

key!(InterKey);
key!(LightKey);
key!(MatKey);
key!(MeshKey);
key!(ReactKey);
key!(RegionKey);
key!(SpecKey);
key!(StateKey);
key!(SurfKey);