Skip to main content

crypto_bigint/limb/
bit_and.rs

1//! Limb bit and operations.
2
3use super::Limb;
4use core::ops::{BitAnd, BitAndAssign};
5
6impl Limb {
7    /// Calculates `a & b`.
8    #[inline(always)]
9    #[must_use]
10    pub const fn bitand(self, rhs: Self) -> Self {
11        Limb(self.0 & rhs.0)
12    }
13}
14
15impl BitAnd for Limb {
16    type Output = Limb;
17
18    #[inline(always)]
19    fn bitand(self, rhs: Self) -> Self::Output {
20        self.bitand(rhs)
21    }
22}
23
24impl BitAnd<&Limb> for Limb {
25    type Output = Limb;
26
27    #[inline(always)]
28    fn bitand(self, rhs: &Self) -> Self::Output {
29        self.bitand(*rhs)
30    }
31}
32
33impl BitAndAssign for Limb {
34    fn bitand_assign(&mut self, rhs: Self) {
35        self.0 &= rhs.0;
36    }
37}
38
39impl BitAndAssign<&Limb> for Limb {
40    fn bitand_assign(&mut self, rhs: &Limb) {
41        self.0 &= rhs.0;
42    }
43}