1use array_map::Indexable;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, Serialize, Deserialize, Hash, PartialEq, Eq)]
8#[repr(u8)]
9#[derive(Indexable)]
10pub enum Sign {
11 Pos,
13 Neg,
15}
16
17impl Sign {
18 #[inline]
20 pub const fn as_int(&self) -> i64 {
21 match self {
22 Self::Pos => 1,
23 Self::Neg => -1,
24 }
25 }
26
27 #[inline]
29 pub const fn is_pos(&self) -> bool {
30 matches!(self, Sign::Pos)
31 }
32
33 #[inline]
35 pub const fn is_neg(&self) -> bool {
36 matches!(self, Sign::Neg)
37 }
38}
39
40impl std::ops::Not for Sign {
41 type Output = Self;
42 fn not(self) -> Self::Output {
44 match self {
45 Self::Pos => Self::Neg,
46 Self::Neg => Self::Pos,
47 }
48 }
49}