1
use crate::{Denominator, Numerator, Q};
2
use core::ops::{Add, Neg, Sub};
3

            
4
impl<Nl, Dl, Nr, Dr, No, Do> Sub<Q<Nr, Dr>> for Q<Nl, Dl>
5
where
6
    Self: Add<<Q<Nr, Dr> as Neg>::Output, Output = Q<No, Do>>,
7
    Q<Nr, Dr>: Neg,
8
    Nl: Numerator<Dl>,
9
    Dl: Denominator,
10
    Nr: Numerator<Dr>,
11
    Dr: Denominator,
12
    No: Numerator<Do>,
13
    Do: Denominator,
14
{
15
    type Output = Q<No, Do>;
16

            
17
2
    fn sub(self, rhs: Q<Nr, Dr>) -> Self::Output {
18
2
        let _ = rhs;
19
2
        Self::Output::new()
20
2
    }
21
}
22

            
23
#[cfg(test)]
24
mod tests {
25
    use super::*;
26
    use typenum::consts::*;
27

            
28
    #[test]
29
1
    fn test_sub() {
30
1
        // positive - zero
31
1
        assert!(Q::<P1, P2>::new() - Q::<Z0>::new() == Q::<P1, P2>::new());
32

            
33
        // positive - positive
34
1
        assert!(Q::<P1, P2>::new() - Q::<P1, P3>::new() == Q::<P1, P6>::new());
35
1
    }
36
}