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