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
use std::fmt;

use super::Aliphatic;

/// Atomic symbols that can be aromatic.
#[derive(Debug,PartialEq)]
pub enum Aromatic {
    B, C, N, O, P, S
}

impl Aromatic {
    /// The valence targets available to this aromatic.
    pub fn targets(&self) -> &[u8] {
        match self {
            Self::B => &[ 3 ],
            Self::C => &[ 4 ],
            Self::N => &[ 3, 5 ],
            Self::O => &[ 2 ],
            Self::P => &[ 3, 5 ],
            Self::S => &[ 2, 4, 6 ]
        }
    }
}

impl Into<Aliphatic> for &Aromatic {
    fn into(self) -> Aliphatic {
        match self {
            Aromatic::B => Aliphatic::B,
            Aromatic::C => Aliphatic::C,
            Aromatic::N => Aliphatic::N,
            Aromatic::O => Aliphatic::O,
            Aromatic::P => Aliphatic::P,
            Aromatic::S => Aliphatic::S
        }
    }
}

impl fmt::Display for Aromatic {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", match self {
            Self::B => "b",
            Self::C => "c",
            Self::N => "n",
            Self::O => "o",
            Self::P => "p",
            Self::S => "s"
        })
    }
}