1use std::fmt;
2
3#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum ChargeSign {
6 Positive,
8 Negative,
10}
11
12impl ChargeSign {
13 #[must_use]
15 pub const fn is_positive(self) -> bool {
16 matches!(self, Self::Positive)
17 }
18
19 #[must_use]
21 pub const fn is_negative(self) -> bool {
22 matches!(self, Self::Negative)
23 }
24}
25
26impl fmt::Display for ChargeSign {
27 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
28 let value = match self {
29 Self::Positive => "+",
30 Self::Negative => "-",
31 };
32
33 formatter.write_str(value)
34 }
35}