crypto_bigint/int/
bit_not.rs1use core::ops::Not;
4
5use crate::{Uint, Wrapping};
6
7use super::Int;
8
9impl<const LIMBS: usize> Int<LIMBS> {
10 #[inline(always)]
12 pub const fn not(&self) -> Self {
13 Self(Uint::not(&self.0))
14 }
15}
16
17impl<const LIMBS: usize> Not for Int<LIMBS> {
18 type Output = Self;
19
20 fn not(self) -> Self {
21 Self::not(&self)
22 }
23}
24
25impl<const LIMBS: usize> Not for Wrapping<Int<LIMBS>> {
26 type Output = Self;
27
28 fn not(self) -> <Self as Not>::Output {
29 Wrapping(self.0.not())
30 }
31}
32
33#[cfg(test)]
34mod tests {
35 use crate::I128;
36
37 #[test]
38 fn bitnot_ok() {
39 assert_eq!(I128::ZERO.not(), I128::MINUS_ONE);
40 assert_eq!(I128::MAX.not(), I128::MIN);
41 }
42}