crypto-bigint 0.7.3

Pure Rust implementation of a big integer library which has been designed from the ground-up for use in cryptographic applications. Provides constant-time, no_std-friendly implementations of modern formulas using const generics.
Documentation
//! Limb negation

use crate::{Limb, NegMod, NonZero, WrappingNeg};

impl Limb {
    /// Perform wrapping negation.
    #[inline(always)]
    #[must_use]
    pub const fn wrapping_neg(self) -> Self {
        Limb(self.0.wrapping_neg())
    }
}

impl WrappingNeg for Limb {
    #[inline]
    fn wrapping_neg(&self) -> Self {
        Self(self.0.wrapping_neg())
    }
}

impl NegMod for Limb {
    type Output = Self;

    fn neg_mod(&self, p: &NonZero<Self>) -> Self::Output {
        let nz = self.is_nonzero();
        let res = p.borrowing_sub(*self, Limb::ZERO).0;
        Self::select(Limb::ZERO, res, nz)
    }
}