Expand description
The bitwise AND operator &
.
Note that Rhs
is Self
by default, but this is not mandatory.
Examples
An implementation of BitAnd
for a wrapper around bool
.
use std::ops::BitAnd;
#[derive(Debug, PartialEq)]
struct Scalar(bool);
impl BitAnd for Scalar {
type Output = Self;
// rhs is the "right-hand side" of the expression `a & b`
fn bitand(self, rhs: Self) -> Self::Output {
Self(self.0 & rhs.0)
}
}
assert_eq!(Scalar(true) & Scalar(true), Scalar(true));
assert_eq!(Scalar(true) & Scalar(false), Scalar(false));
assert_eq!(Scalar(false) & Scalar(true), Scalar(false));
assert_eq!(Scalar(false) & Scalar(false), Scalar(false));
An implementation of BitAnd
for a wrapper around Vec<bool>
.
use std::ops::BitAnd;
#[derive(Debug, PartialEq)]
struct BooleanVector(Vec<bool>);
impl BitAnd for BooleanVector {
type Output = Self;
fn bitand(self, Self(rhs): Self) -> Self::Output {
let Self(lhs) = self;
assert_eq!(lhs.len(), rhs.len());
Self(
lhs.iter()
.zip(rhs.iter())
.map(|(x, y)| *x & *y)
.collect()
)
}
}
let bv1 = BooleanVector(vec![true, true, false, false]);
let bv2 = BooleanVector(vec![true, false, true, false]);
let expected = BooleanVector(vec![true, false, false, false]);
assert_eq!(bv1 & bv2, expected);
Required Associated Types
Required Methods
Implementors
impl BitAnd<FallocateFlags> for FallocateFlags
impl BitAnd<FallocateFlags> for FallocateFlags
type Output = FallocateFlags
impl BitAnd<RenameFlags> for RenameFlags
impl BitAnd<RenameFlags> for RenameFlags
type Output = RenameFlags
impl BitAnd<SpliceFFlags> for SpliceFFlags
impl BitAnd<SpliceFFlags> for SpliceFFlags
type Output = SpliceFFlags
impl BitAnd<DeleteModuleFlags> for DeleteModuleFlags
impl BitAnd<DeleteModuleFlags> for DeleteModuleFlags
type Output = DeleteModuleFlags
impl BitAnd<ModuleInitFlags> for ModuleInitFlags
impl BitAnd<ModuleInitFlags> for ModuleInitFlags
type Output = ModuleInitFlags
impl BitAnd<InterfaceFlags> for InterfaceFlags
impl BitAnd<InterfaceFlags> for InterfaceFlags
type Output = InterfaceFlags
impl BitAnd<CloneFlags> for CloneFlags
impl BitAnd<CloneFlags> for CloneFlags
type Output = CloneFlags
impl BitAnd<EpollCreateFlags> for EpollCreateFlags
impl BitAnd<EpollCreateFlags> for EpollCreateFlags
type Output = EpollCreateFlags
impl BitAnd<EpollFlags> for EpollFlags
impl BitAnd<EpollFlags> for EpollFlags
type Output = EpollFlags
impl BitAnd<AddWatchFlags> for AddWatchFlags
impl BitAnd<AddWatchFlags> for AddWatchFlags
type Output = AddWatchFlags
impl BitAnd<MemFdCreateFlag> for MemFdCreateFlag
impl BitAnd<MemFdCreateFlag> for MemFdCreateFlag
type Output = MemFdCreateFlag
impl BitAnd<MRemapFlags> for MRemapFlags
impl BitAnd<MRemapFlags> for MRemapFlags
type Output = MRemapFlags
impl BitAnd<MlockAllFlags> for MlockAllFlags
impl BitAnd<MlockAllFlags> for MlockAllFlags
type Output = MlockAllFlags
impl BitAnd<QuotaValidFlags> for QuotaValidFlags
impl BitAnd<QuotaValidFlags> for QuotaValidFlags
type Output = QuotaValidFlags
impl BitAnd<TimestampingFlag> for TimestampingFlag
impl BitAnd<TimestampingFlag> for TimestampingFlag
type Output = TimestampingFlag
impl BitAnd<ControlFlags> for ControlFlags
impl BitAnd<ControlFlags> for ControlFlags
type Output = ControlFlags
impl BitAnd<InputFlags> for InputFlags
impl BitAnd<InputFlags> for InputFlags
type Output = InputFlags
impl BitAnd<LocalFlags> for LocalFlags
impl BitAnd<LocalFlags> for LocalFlags
type Output = LocalFlags
impl BitAnd<OutputFlags> for OutputFlags
impl BitAnd<OutputFlags> for OutputFlags
type Output = OutputFlags
impl BitAnd<TimerSetTimeFlags> for TimerSetTimeFlags
impl BitAnd<TimerSetTimeFlags> for TimerSetTimeFlags
type Output = TimerSetTimeFlags
impl BitAnd<TimerFlags> for TimerFlags
impl BitAnd<TimerFlags> for TimerFlags
type Output = TimerFlags
impl BitAnd<WaitPidFlag> for WaitPidFlag
impl BitAnd<WaitPidFlag> for WaitPidFlag
type Output = WaitPidFlag
impl BitAnd<AccessFlags> for AccessFlags
impl BitAnd<AccessFlags> for AccessFlags
type Output = AccessFlags
sourceimpl BitAnd<Saturating<i8>> for Saturating<i8>
impl BitAnd<Saturating<i8>> for Saturating<i8>
type Output = Saturating<i8>
sourceimpl BitAnd<Saturating<i16>> for Saturating<i16>
impl BitAnd<Saturating<i16>> for Saturating<i16>
type Output = Saturating<i16>
sourceimpl BitAnd<Saturating<i32>> for Saturating<i32>
impl BitAnd<Saturating<i32>> for Saturating<i32>
type Output = Saturating<i32>
sourceimpl BitAnd<Saturating<i64>> for Saturating<i64>
impl BitAnd<Saturating<i64>> for Saturating<i64>
type Output = Saturating<i64>
sourceimpl BitAnd<Saturating<i128>> for Saturating<i128>
impl BitAnd<Saturating<i128>> for Saturating<i128>
type Output = Saturating<i128>
sourceimpl BitAnd<Saturating<isize>> for Saturating<isize>
impl BitAnd<Saturating<isize>> for Saturating<isize>
type Output = Saturating<isize>
sourceimpl BitAnd<Saturating<u8>> for Saturating<u8>
impl BitAnd<Saturating<u8>> for Saturating<u8>
type Output = Saturating<u8>
sourceimpl BitAnd<Saturating<u16>> for Saturating<u16>
impl BitAnd<Saturating<u16>> for Saturating<u16>
type Output = Saturating<u16>
sourceimpl BitAnd<Saturating<u32>> for Saturating<u32>
impl BitAnd<Saturating<u32>> for Saturating<u32>
type Output = Saturating<u32>
sourceimpl BitAnd<Saturating<u64>> for Saturating<u64>
impl BitAnd<Saturating<u64>> for Saturating<u64>
type Output = Saturating<u64>
sourceimpl BitAnd<Saturating<u128>> for Saturating<u128>
impl BitAnd<Saturating<u128>> for Saturating<u128>
type Output = Saturating<u128>
sourceimpl BitAnd<Saturating<usize>> for Saturating<usize>
impl BitAnd<Saturating<usize>> for Saturating<usize>
type Output = Saturating<usize>
sourceimpl BitAnd<CMSOptions> for CMSOptions
impl BitAnd<CMSOptions> for CMSOptions
type Output = CMSOptions
sourceimpl BitAnd<Pkcs7Flags> for Pkcs7Flags
impl BitAnd<Pkcs7Flags> for Pkcs7Flags
type Output = Pkcs7Flags
sourceimpl BitAnd<ExtensionContext> for ExtensionContext
impl BitAnd<ExtensionContext> for ExtensionContext
type Output = ExtensionContext
sourceimpl BitAnd<ShutdownState> for ShutdownState
impl BitAnd<ShutdownState> for ShutdownState
type Output = ShutdownState
sourceimpl BitAnd<SslOptions> for SslOptions
impl BitAnd<SslOptions> for SslOptions
type Output = SslOptions
sourceimpl BitAnd<SslSessionCacheMode> for SslSessionCacheMode
impl BitAnd<SslSessionCacheMode> for SslSessionCacheMode
type Output = SslSessionCacheMode
sourceimpl BitAnd<SslVerifyMode> for SslVerifyMode
impl BitAnd<SslVerifyMode> for SslVerifyMode
type Output = SslVerifyMode
sourceimpl BitAnd<X509CheckFlags> for X509CheckFlags
impl BitAnd<X509CheckFlags> for X509CheckFlags
type Output = X509CheckFlags
sourceimpl BitAnd<X509VerifyFlags> for X509VerifyFlags
impl BitAnd<X509VerifyFlags> for X509VerifyFlags
type Output = X509VerifyFlags
sourceimpl<'_> BitAnd<&Saturating<i8>> for Saturating<i8>
impl<'_> BitAnd<&Saturating<i8>> for Saturating<i8>
type Output = <Saturating<i8> as BitAnd<Saturating<i8>>>::Output
sourceimpl<'_> BitAnd<&Saturating<i16>> for Saturating<i16>
impl<'_> BitAnd<&Saturating<i16>> for Saturating<i16>
type Output = <Saturating<i16> as BitAnd<Saturating<i16>>>::Output
sourceimpl<'_> BitAnd<&Saturating<i32>> for Saturating<i32>
impl<'_> BitAnd<&Saturating<i32>> for Saturating<i32>
type Output = <Saturating<i32> as BitAnd<Saturating<i32>>>::Output
sourceimpl<'_> BitAnd<&Saturating<i64>> for Saturating<i64>
impl<'_> BitAnd<&Saturating<i64>> for Saturating<i64>
type Output = <Saturating<i64> as BitAnd<Saturating<i64>>>::Output
sourceimpl<'_> BitAnd<&Saturating<i128>> for Saturating<i128>
impl<'_> BitAnd<&Saturating<i128>> for Saturating<i128>
type Output = <Saturating<i128> as BitAnd<Saturating<i128>>>::Output
sourceimpl<'_> BitAnd<&Saturating<isize>> for Saturating<isize>
impl<'_> BitAnd<&Saturating<isize>> for Saturating<isize>
type Output = <Saturating<isize> as BitAnd<Saturating<isize>>>::Output
sourceimpl<'_> BitAnd<&Saturating<u8>> for Saturating<u8>
impl<'_> BitAnd<&Saturating<u8>> for Saturating<u8>
type Output = <Saturating<u8> as BitAnd<Saturating<u8>>>::Output
sourceimpl<'_> BitAnd<&Saturating<u16>> for Saturating<u16>
impl<'_> BitAnd<&Saturating<u16>> for Saturating<u16>
type Output = <Saturating<u16> as BitAnd<Saturating<u16>>>::Output
sourceimpl<'_> BitAnd<&Saturating<u32>> for Saturating<u32>
impl<'_> BitAnd<&Saturating<u32>> for Saturating<u32>
type Output = <Saturating<u32> as BitAnd<Saturating<u32>>>::Output
sourceimpl<'_> BitAnd<&Saturating<u64>> for Saturating<u64>
impl<'_> BitAnd<&Saturating<u64>> for Saturating<u64>
type Output = <Saturating<u64> as BitAnd<Saturating<u64>>>::Output
sourceimpl<'_> BitAnd<&Saturating<u128>> for Saturating<u128>
impl<'_> BitAnd<&Saturating<u128>> for Saturating<u128>
type Output = <Saturating<u128> as BitAnd<Saturating<u128>>>::Output
sourceimpl<'_> BitAnd<&Saturating<usize>> for Saturating<usize>
impl<'_> BitAnd<&Saturating<usize>> for Saturating<usize>
type Output = <Saturating<usize> as BitAnd<Saturating<usize>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<i8>> for &Saturating<i8>
impl<'_, '_> BitAnd<&Saturating<i8>> for &Saturating<i8>
type Output = <Saturating<i8> as BitAnd<Saturating<i8>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<i16>> for &Saturating<i16>
impl<'_, '_> BitAnd<&Saturating<i16>> for &Saturating<i16>
type Output = <Saturating<i16> as BitAnd<Saturating<i16>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<i32>> for &Saturating<i32>
impl<'_, '_> BitAnd<&Saturating<i32>> for &Saturating<i32>
type Output = <Saturating<i32> as BitAnd<Saturating<i32>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<i64>> for &Saturating<i64>
impl<'_, '_> BitAnd<&Saturating<i64>> for &Saturating<i64>
type Output = <Saturating<i64> as BitAnd<Saturating<i64>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<i128>> for &Saturating<i128>
impl<'_, '_> BitAnd<&Saturating<i128>> for &Saturating<i128>
type Output = <Saturating<i128> as BitAnd<Saturating<i128>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<isize>> for &Saturating<isize>
impl<'_, '_> BitAnd<&Saturating<isize>> for &Saturating<isize>
type Output = <Saturating<isize> as BitAnd<Saturating<isize>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<u8>> for &Saturating<u8>
impl<'_, '_> BitAnd<&Saturating<u8>> for &Saturating<u8>
type Output = <Saturating<u8> as BitAnd<Saturating<u8>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<u16>> for &Saturating<u16>
impl<'_, '_> BitAnd<&Saturating<u16>> for &Saturating<u16>
type Output = <Saturating<u16> as BitAnd<Saturating<u16>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<u32>> for &Saturating<u32>
impl<'_, '_> BitAnd<&Saturating<u32>> for &Saturating<u32>
type Output = <Saturating<u32> as BitAnd<Saturating<u32>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<u64>> for &Saturating<u64>
impl<'_, '_> BitAnd<&Saturating<u64>> for &Saturating<u64>
type Output = <Saturating<u64> as BitAnd<Saturating<u64>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<u128>> for &Saturating<u128>
impl<'_, '_> BitAnd<&Saturating<u128>> for &Saturating<u128>
type Output = <Saturating<u128> as BitAnd<Saturating<u128>>>::Output
sourceimpl<'_, '_> BitAnd<&Saturating<usize>> for &Saturating<usize>
impl<'_, '_> BitAnd<&Saturating<usize>> for &Saturating<usize>
type Output = <Saturating<usize> as BitAnd<Saturating<usize>>>::Output
sourceimpl<'_, '_, T, A> BitAnd<&BTreeSet<T, A>> for &BTreeSet<T, A> where
T: Ord + Clone,
A: Allocator + Clone,
impl<'_, '_, T, A> BitAnd<&BTreeSet<T, A>> for &BTreeSet<T, A> where
T: Ord + Clone,
A: Allocator + Clone,
sourceimpl<'_, '_, T, S1, S2> BitAnd<&IndexSet<T, S2>> for &IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<'_, '_, T, S1, S2> BitAnd<&IndexSet<T, S2>> for &IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
sourceimpl<'_, '_, T, S> BitAnd<&HashSet<T, S>> for &otter_nodejs_tests::HashSet<T, S> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'_, '_, T, S> BitAnd<&HashSet<T, S>> for &otter_nodejs_tests::HashSet<T, S> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'_, '_, T, S, A> BitAnd<&HashSet<T, S, A>> for &HashSet<T, S, A> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
A: Allocator + Clone,
impl<'_, '_, T, S, A> BitAnd<&HashSet<T, S, A>> for &HashSet<T, S, A> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
A: Allocator + Clone,
type Output = HashSet<T, S, Global>
sourceimpl<'_, T, const LANES: usize> BitAnd<&Simd<T, LANES>> for Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: BitAnd<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as BitAnd<Simd<T, LANES>>>::Output == Simd<T, LANES>,
impl<'_, T, const LANES: usize> BitAnd<&Simd<T, LANES>> for Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: BitAnd<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as BitAnd<Simd<T, LANES>>>::Output == Simd<T, LANES>,
sourceimpl<'_, T, const LANES: usize> BitAnd<Simd<T, LANES>> for &Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: BitAnd<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as BitAnd<Simd<T, LANES>>>::Output == Simd<T, LANES>,
impl<'_, T, const LANES: usize> BitAnd<Simd<T, LANES>> for &Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: BitAnd<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as BitAnd<Simd<T, LANES>>>::Output == Simd<T, LANES>,
sourceimpl<'a> BitAnd<Saturating<i8>> for &'a Saturating<i8>
impl<'a> BitAnd<Saturating<i8>> for &'a Saturating<i8>
type Output = <Saturating<i8> as BitAnd<Saturating<i8>>>::Output
sourceimpl<'a> BitAnd<Saturating<i16>> for &'a Saturating<i16>
impl<'a> BitAnd<Saturating<i16>> for &'a Saturating<i16>
type Output = <Saturating<i16> as BitAnd<Saturating<i16>>>::Output
sourceimpl<'a> BitAnd<Saturating<i32>> for &'a Saturating<i32>
impl<'a> BitAnd<Saturating<i32>> for &'a Saturating<i32>
type Output = <Saturating<i32> as BitAnd<Saturating<i32>>>::Output
sourceimpl<'a> BitAnd<Saturating<i64>> for &'a Saturating<i64>
impl<'a> BitAnd<Saturating<i64>> for &'a Saturating<i64>
type Output = <Saturating<i64> as BitAnd<Saturating<i64>>>::Output
sourceimpl<'a> BitAnd<Saturating<i128>> for &'a Saturating<i128>
impl<'a> BitAnd<Saturating<i128>> for &'a Saturating<i128>
type Output = <Saturating<i128> as BitAnd<Saturating<i128>>>::Output
sourceimpl<'a> BitAnd<Saturating<isize>> for &'a Saturating<isize>
impl<'a> BitAnd<Saturating<isize>> for &'a Saturating<isize>
type Output = <Saturating<isize> as BitAnd<Saturating<isize>>>::Output
sourceimpl<'a> BitAnd<Saturating<u8>> for &'a Saturating<u8>
impl<'a> BitAnd<Saturating<u8>> for &'a Saturating<u8>
type Output = <Saturating<u8> as BitAnd<Saturating<u8>>>::Output
sourceimpl<'a> BitAnd<Saturating<u16>> for &'a Saturating<u16>
impl<'a> BitAnd<Saturating<u16>> for &'a Saturating<u16>
type Output = <Saturating<u16> as BitAnd<Saturating<u16>>>::Output
sourceimpl<'a> BitAnd<Saturating<u32>> for &'a Saturating<u32>
impl<'a> BitAnd<Saturating<u32>> for &'a Saturating<u32>
type Output = <Saturating<u32> as BitAnd<Saturating<u32>>>::Output
sourceimpl<'a> BitAnd<Saturating<u64>> for &'a Saturating<u64>
impl<'a> BitAnd<Saturating<u64>> for &'a Saturating<u64>
type Output = <Saturating<u64> as BitAnd<Saturating<u64>>>::Output
sourceimpl<'a> BitAnd<Saturating<u128>> for &'a Saturating<u128>
impl<'a> BitAnd<Saturating<u128>> for &'a Saturating<u128>
type Output = <Saturating<u128> as BitAnd<Saturating<u128>>>::Output
sourceimpl<'a> BitAnd<Saturating<usize>> for &'a Saturating<usize>
impl<'a> BitAnd<Saturating<usize>> for &'a Saturating<usize>
type Output = <Saturating<usize> as BitAnd<Saturating<usize>>>::Output
sourceimpl<'lhs, 'rhs, T, const LANES: usize> BitAnd<&'rhs Simd<T, LANES>> for &'lhs Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: BitAnd<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as BitAnd<Simd<T, LANES>>>::Output == Simd<T, LANES>,
impl<'lhs, 'rhs, T, const LANES: usize> BitAnd<&'rhs Simd<T, LANES>> for &'lhs Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: BitAnd<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as BitAnd<Simd<T, LANES>>>::Output == Simd<T, LANES>,
sourceimpl<T, const LANES: usize> BitAnd<bool> for Mask<T, LANES> where
T: MaskElement,
LaneCount<LANES>: SupportedLaneCount,
impl<T, const LANES: usize> BitAnd<bool> for Mask<T, LANES> where
T: MaskElement,
LaneCount<LANES>: SupportedLaneCount,
sourceimpl<T, const LANES: usize> BitAnd<Mask<T, LANES>> for bool where
T: MaskElement,
LaneCount<LANES>: SupportedLaneCount,
impl<T, const LANES: usize> BitAnd<Mask<T, LANES>> for bool where
T: MaskElement,
LaneCount<LANES>: SupportedLaneCount,
sourceimpl<T, const LANES: usize> BitAnd<Mask<T, LANES>> for Mask<T, LANES> where
T: MaskElement,
LaneCount<LANES>: SupportedLaneCount,
impl<T, const LANES: usize> BitAnd<Mask<T, LANES>> for Mask<T, LANES> where
T: MaskElement,
LaneCount<LANES>: SupportedLaneCount,
sourceimpl<Ul, Bl, Ur> BitAnd<Ur> for UInt<Ul, Bl> where
Ul: Unsigned,
Bl: Bit,
Ur: Unsigned,
UInt<Ul, Bl>: PrivateAnd<Ur>,
<UInt<Ul, Bl> as PrivateAnd<Ur>>::Output: Trim,
impl<Ul, Bl, Ur> BitAnd<Ur> for UInt<Ul, Bl> where
Ul: Unsigned,
Bl: Bit,
Ur: Unsigned,
UInt<Ul, Bl>: PrivateAnd<Ur>,
<UInt<Ul, Bl> as PrivateAnd<Ur>>::Output: Trim,
Anding unsigned integers.
We use our PrivateAnd
operator and then Trim
the output.