rusty-numbers/src/lib.rs

44 lines
775 B
Rust

#![forbid(unsafe_code)]
use std::ops::Not;
pub mod bigint;
pub mod rational;
pub mod seq;
/// Dummy trait for implementing generics on unsigned number types
pub trait Unsigned: PartialEq + PartialOrd {}
impl Unsigned for u8 {}
impl Unsigned for u16 {}
impl Unsigned for u32 {}
impl Unsigned for u64 {}
impl Unsigned for usize {}
impl Unsigned for u128 {}
#[derive(Debug, Copy, Clone)]
pub enum Sign {
Positive,
Negative
}
impl Not for Sign {
type Output = Sign;
fn not(self) -> Self::Output {
match self {
Self::Positive => Self::Negative,
Self::Negative => Self::Positive,
_ => unreachable!()
}
}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}