1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use core::ops::Neg;

use super::DynResidue;

impl<const LIMBS: usize> DynResidue<LIMBS> {
    /// Negates the number.
    pub const fn neg(&self) -> Self {
        Self::zero(self.residue_params).sub(self)
    }
}

impl<const LIMBS: usize> Neg for DynResidue<LIMBS> {
    type Output = Self;
    fn neg(self) -> Self {
        DynResidue::neg(&self)
    }
}

impl<const LIMBS: usize> Neg for &DynResidue<LIMBS> {
    type Output = DynResidue<LIMBS>;
    fn neg(self) -> DynResidue<LIMBS> {
        DynResidue::neg(self)
    }
}