use_oxidation_state/
oxidation_sign.rs1use std::fmt;
2
3#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum OxidationSign {
6 Positive,
8 Negative,
10 Zero,
12}
13
14impl OxidationSign {
15 #[must_use]
17 pub const fn is_positive(self) -> bool {
18 matches!(self, Self::Positive)
19 }
20
21 #[must_use]
23 pub const fn is_negative(self) -> bool {
24 matches!(self, Self::Negative)
25 }
26
27 #[must_use]
29 pub const fn is_zero(self) -> bool {
30 matches!(self, Self::Zero)
31 }
32}
33
34impl fmt::Display for OxidationSign {
35 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
36 match self {
37 Self::Positive => formatter.write_str("+"),
38 Self::Negative => formatter.write_str("-"),
39 Self::Zero => formatter.write_str("0"),
40 }
41 }
42}