use std::fmt; #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct LogicLong { pub high: i32, pub low: i32, } impl LogicLong { pub const ZERO: LogicLong = LogicLong { high: 0, low: 0 }; pub const fn new(high: i32, low: i32) -> Self { Self { high, low } } pub const fn from_i64(value: i64) -> Self { Self { high: (value >> 32) as i32, low: value as i32, } } pub const fn to_i64(self) -> i64 { ((self.high as i64) << 32) | (self.low as u32 as i64) } pub const fn is_zero(self) -> bool { self.high == 0 && self.low == 0 } } impl fmt::Display for LogicLong { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "LogicLong({}-{})", self.high, self.low) } } impl From for LogicLong { fn from(value: i64) -> Self { Self::from_i64(value) } } impl From for i64 { fn from(value: LogicLong) -> Self { value.to_i64() } }