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
use crate::raw::InnerElement;

#[derive(Copy, Debug, Clone)]
pub struct Element {
    name: &'static str,
    symbol: &'static str,
    atomic_mass: f64,
    atomic_number: u8,
    raw: &'static InnerElement,
}

impl Element {
    pub fn name(&self) -> String {
        self.name.to_string()
    }

    pub fn symbol(&self) -> String {
        self.symbol.to_string()
    }

    pub const fn atomic_mass(&self) -> f64 {
        self.atomic_mass
    }

    pub const fn atomic_number(&self) -> u8 {
        self.atomic_number
    }

    pub const fn data(&self) -> &'static InnerElement {
        self.raw
    }

    pub const fn new(
        name: &'static str,
        symbol: &'static str,
        atomic_mass: f64,
        atomic_number: u8,
        raw: &'static InnerElement,
    ) -> Self {
        Self {
            name,
            symbol,
            atomic_mass,
            atomic_number,
            raw,
        }
    }
}