typerat 0.0.4

Type-level rational numbers based on `typenum`.
Documentation
use crate::{Denominator, Numerator, Q};
use core::ops::Neg;

impl<N, D, No> Neg for Q<N, D>
where
    N: Numerator<D> + Neg<Output = No>,
    D: Denominator,
    No: Numerator<D>,
{
    type Output = Q<No, D>;

    fn neg(self) -> Self::Output {
        Self::Output::new()
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use typenum::consts::*;

    #[test]
    fn test_neg() {
        // zero
        assert!(-Q::<Z0>::new() == Q::<Z0>::new());

        // positive
        assert!(-Q::<P1, P2>::new() == Q::<N1, P2>::new());

        // negative
        assert!(-Q::<N1, P2>::new() == Q::<P1, P2>::new());
    }
}