crypto_bigint/uint/modular/runtime_mod/
runtime_neg.rs

1use core::ops::Neg;
2
3use super::DynResidue;
4
5impl<const LIMBS: usize> DynResidue<LIMBS> {
6    /// Negates the number.
7    pub const fn neg(&self) -> Self {
8        Self::zero(self.residue_params).sub(self)
9    }
10}
11
12impl<const LIMBS: usize> Neg for DynResidue<LIMBS> {
13    type Output = Self;
14    fn neg(self) -> Self {
15        DynResidue::neg(&self)
16    }
17}
18
19impl<const LIMBS: usize> Neg for &DynResidue<LIMBS> {
20    type Output = DynResidue<LIMBS>;
21    fn neg(self) -> DynResidue<LIMBS> {
22        DynResidue::neg(self)
23    }
24}