use array_map::Indexable;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Hash, PartialEq, Eq)]
#[repr(u8)]
#[derive(Indexable)]
pub enum Sign {
Pos,
Neg,
}
impl Sign {
#[inline]
pub const fn as_int(&self) -> i64 {
match self {
Self::Pos => 1,
Self::Neg => -1,
}
}
#[inline]
pub const fn is_pos(&self) -> bool {
matches!(self, Sign::Pos)
}
#[inline]
pub const fn is_neg(&self) -> bool {
matches!(self, Sign::Neg)
}
}
impl std::ops::Not for Sign {
type Output = Self;
fn not(self) -> Self::Output {
match self {
Self::Pos => Self::Neg,
Self::Neg => Self::Pos,
}
}
}