pub trait BitAnd<Rhs = Self> {
type Output;
// Required method
fn bitand(self, rhs: Rhs) -> Self::Output;
}
Available on crate feature
std
only.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§
1.74.0 · source§impl BitAnd for Saturating<i8>
impl BitAnd for Saturating<i8>
type Output = Saturating<i8>
1.74.0 · source§impl BitAnd for Saturating<i16>
impl BitAnd for Saturating<i16>
type Output = Saturating<i16>
1.74.0 · source§impl BitAnd for Saturating<i32>
impl BitAnd for Saturating<i32>
type Output = Saturating<i32>
1.74.0 · source§impl BitAnd for Saturating<i64>
impl BitAnd for Saturating<i64>
type Output = Saturating<i64>
1.74.0 · source§impl BitAnd for Saturating<i128>
impl BitAnd for Saturating<i128>
type Output = Saturating<i128>
1.74.0 · source§impl BitAnd for Saturating<isize>
impl BitAnd for Saturating<isize>
type Output = Saturating<isize>
1.74.0 · source§impl BitAnd for Saturating<u8>
impl BitAnd for Saturating<u8>
type Output = Saturating<u8>
1.74.0 · source§impl BitAnd for Saturating<u16>
impl BitAnd for Saturating<u16>
type Output = Saturating<u16>
1.74.0 · source§impl BitAnd for Saturating<u32>
impl BitAnd for Saturating<u32>
type Output = Saturating<u32>
1.74.0 · source§impl BitAnd for Saturating<u64>
impl BitAnd for Saturating<u64>
type Output = Saturating<u64>
1.74.0 · source§impl BitAnd for Saturating<u128>
impl BitAnd for Saturating<u128>
type Output = Saturating<u128>
1.74.0 · source§impl BitAnd for Saturating<usize>
impl BitAnd for Saturating<usize>
type Output = Saturating<usize>
source§impl BitAnd for CreateFlags
impl BitAnd for CreateFlags
type Output = CreateFlags
source§impl BitAnd for WatchFlags
impl BitAnd for WatchFlags
type Output = WatchFlags
source§impl BitAnd for FallocateFlags
impl BitAnd for FallocateFlags
type Output = FallocateFlags
source§impl BitAnd for MemfdFlags
impl BitAnd for MemfdFlags
type Output = MemfdFlags
source§impl BitAnd for RenameFlags
impl BitAnd for RenameFlags
type Output = RenameFlags
source§impl BitAnd for ResolveFlags
impl BitAnd for ResolveFlags
type Output = ResolveFlags
source§impl BitAnd for StatVfsMountFlags
impl BitAnd for StatVfsMountFlags
type Output = StatVfsMountFlags
source§impl BitAnd for StatxFlags
impl BitAnd for StatxFlags
type Output = StatxFlags
source§impl BitAnd for ReadWriteFlags
impl BitAnd for ReadWriteFlags
type Output = ReadWriteFlags
source§impl BitAnd for MountFlags
impl BitAnd for MountFlags
type Output = MountFlags
source§impl BitAnd for MountPropagationFlags
impl BitAnd for MountPropagationFlags
type Output = MountPropagationFlags
source§impl BitAnd for UnmountFlags
impl BitAnd for UnmountFlags
type Output = UnmountFlags
source§impl BitAnd for XattrFlags
impl BitAnd for XattrFlags
type Output = XattrFlags
1.74.0 · source§impl BitAnd<&Saturating<i8>> for &Saturating<i8>
impl BitAnd<&Saturating<i8>> for &Saturating<i8>
1.74.0 · source§impl BitAnd<&Saturating<i8>> for Saturating<i8>
impl BitAnd<&Saturating<i8>> for Saturating<i8>
1.74.0 · source§impl BitAnd<&Saturating<i16>> for &Saturating<i16>
impl BitAnd<&Saturating<i16>> for &Saturating<i16>
1.74.0 · source§impl BitAnd<&Saturating<i16>> for Saturating<i16>
impl BitAnd<&Saturating<i16>> for Saturating<i16>
1.74.0 · source§impl BitAnd<&Saturating<i32>> for &Saturating<i32>
impl BitAnd<&Saturating<i32>> for &Saturating<i32>
1.74.0 · source§impl BitAnd<&Saturating<i32>> for Saturating<i32>
impl BitAnd<&Saturating<i32>> for Saturating<i32>
1.74.0 · source§impl BitAnd<&Saturating<i64>> for &Saturating<i64>
impl BitAnd<&Saturating<i64>> for &Saturating<i64>
1.74.0 · source§impl BitAnd<&Saturating<i64>> for Saturating<i64>
impl BitAnd<&Saturating<i64>> for Saturating<i64>
1.74.0 · source§impl BitAnd<&Saturating<i128>> for &Saturating<i128>
impl BitAnd<&Saturating<i128>> for &Saturating<i128>
1.74.0 · source§impl BitAnd<&Saturating<i128>> for Saturating<i128>
impl BitAnd<&Saturating<i128>> for Saturating<i128>
1.74.0 · source§impl BitAnd<&Saturating<isize>> for &Saturating<isize>
impl BitAnd<&Saturating<isize>> for &Saturating<isize>
1.74.0 · source§impl BitAnd<&Saturating<isize>> for Saturating<isize>
impl BitAnd<&Saturating<isize>> for Saturating<isize>
1.74.0 · source§impl BitAnd<&Saturating<u8>> for &Saturating<u8>
impl BitAnd<&Saturating<u8>> for &Saturating<u8>
1.74.0 · source§impl BitAnd<&Saturating<u8>> for Saturating<u8>
impl BitAnd<&Saturating<u8>> for Saturating<u8>
1.74.0 · source§impl BitAnd<&Saturating<u16>> for &Saturating<u16>
impl BitAnd<&Saturating<u16>> for &Saturating<u16>
1.74.0 · source§impl BitAnd<&Saturating<u16>> for Saturating<u16>
impl BitAnd<&Saturating<u16>> for Saturating<u16>
1.74.0 · source§impl BitAnd<&Saturating<u32>> for &Saturating<u32>
impl BitAnd<&Saturating<u32>> for &Saturating<u32>
1.74.0 · source§impl BitAnd<&Saturating<u32>> for Saturating<u32>
impl BitAnd<&Saturating<u32>> for Saturating<u32>
1.74.0 · source§impl BitAnd<&Saturating<u64>> for &Saturating<u64>
impl BitAnd<&Saturating<u64>> for &Saturating<u64>
1.74.0 · source§impl BitAnd<&Saturating<u64>> for Saturating<u64>
impl BitAnd<&Saturating<u64>> for Saturating<u64>
1.74.0 · source§impl BitAnd<&Saturating<u128>> for &Saturating<u128>
impl BitAnd<&Saturating<u128>> for &Saturating<u128>
1.74.0 · source§impl BitAnd<&Saturating<u128>> for Saturating<u128>
impl BitAnd<&Saturating<u128>> for Saturating<u128>
1.74.0 · source§impl BitAnd<&Saturating<usize>> for &Saturating<usize>
impl BitAnd<&Saturating<usize>> for &Saturating<usize>
1.74.0 · source§impl BitAnd<&Saturating<usize>> for Saturating<usize>
impl BitAnd<&Saturating<usize>> for Saturating<usize>
source§impl BitAnd<&LittleEndian<i16>> for &LittleEndian<i16>
impl BitAnd<&LittleEndian<i16>> for &LittleEndian<i16>
source§impl BitAnd<&LittleEndian<i16>> for LittleEndian<i16>
impl BitAnd<&LittleEndian<i16>> for LittleEndian<i16>
source§impl BitAnd<&LittleEndian<i32>> for &LittleEndian<i32>
impl BitAnd<&LittleEndian<i32>> for &LittleEndian<i32>
source§impl BitAnd<&LittleEndian<i32>> for LittleEndian<i32>
impl BitAnd<&LittleEndian<i32>> for LittleEndian<i32>
source§impl BitAnd<&LittleEndian<i64>> for &LittleEndian<i64>
impl BitAnd<&LittleEndian<i64>> for &LittleEndian<i64>
source§impl BitAnd<&LittleEndian<i64>> for LittleEndian<i64>
impl BitAnd<&LittleEndian<i64>> for LittleEndian<i64>
source§impl BitAnd<&LittleEndian<i128>> for &LittleEndian<i128>
impl BitAnd<&LittleEndian<i128>> for &LittleEndian<i128>
source§impl BitAnd<&LittleEndian<i128>> for LittleEndian<i128>
impl BitAnd<&LittleEndian<i128>> for LittleEndian<i128>
source§impl BitAnd<&LittleEndian<u16>> for &LittleEndian<u16>
impl BitAnd<&LittleEndian<u16>> for &LittleEndian<u16>
source§impl BitAnd<&LittleEndian<u16>> for LittleEndian<u16>
impl BitAnd<&LittleEndian<u16>> for LittleEndian<u16>
source§impl BitAnd<&LittleEndian<u32>> for &LittleEndian<u32>
impl BitAnd<&LittleEndian<u32>> for &LittleEndian<u32>
source§impl BitAnd<&LittleEndian<u32>> for LittleEndian<u32>
impl BitAnd<&LittleEndian<u32>> for LittleEndian<u32>
source§impl BitAnd<&LittleEndian<u64>> for &LittleEndian<u64>
impl BitAnd<&LittleEndian<u64>> for &LittleEndian<u64>
source§impl BitAnd<&LittleEndian<u64>> for LittleEndian<u64>
impl BitAnd<&LittleEndian<u64>> for LittleEndian<u64>
source§impl BitAnd<&LittleEndian<u128>> for &LittleEndian<u128>
impl BitAnd<&LittleEndian<u128>> for &LittleEndian<u128>
source§impl BitAnd<&LittleEndian<u128>> for LittleEndian<u128>
impl BitAnd<&LittleEndian<u128>> for LittleEndian<u128>
source§impl BitAnd<&NativeEndian<i16>> for &NativeEndian<i16>
impl BitAnd<&NativeEndian<i16>> for &NativeEndian<i16>
source§impl BitAnd<&NativeEndian<i16>> for NativeEndian<i16>
impl BitAnd<&NativeEndian<i16>> for NativeEndian<i16>
source§impl BitAnd<&NativeEndian<i32>> for &NativeEndian<i32>
impl BitAnd<&NativeEndian<i32>> for &NativeEndian<i32>
source§impl BitAnd<&NativeEndian<i32>> for NativeEndian<i32>
impl BitAnd<&NativeEndian<i32>> for NativeEndian<i32>
source§impl BitAnd<&NativeEndian<i64>> for &NativeEndian<i64>
impl BitAnd<&NativeEndian<i64>> for &NativeEndian<i64>
source§impl BitAnd<&NativeEndian<i64>> for NativeEndian<i64>
impl BitAnd<&NativeEndian<i64>> for NativeEndian<i64>
source§impl BitAnd<&NativeEndian<i128>> for &NativeEndian<i128>
impl BitAnd<&NativeEndian<i128>> for &NativeEndian<i128>
source§impl BitAnd<&NativeEndian<i128>> for NativeEndian<i128>
impl BitAnd<&NativeEndian<i128>> for NativeEndian<i128>
source§impl BitAnd<&NativeEndian<u16>> for &NativeEndian<u16>
impl BitAnd<&NativeEndian<u16>> for &NativeEndian<u16>
source§impl BitAnd<&NativeEndian<u16>> for NativeEndian<u16>
impl BitAnd<&NativeEndian<u16>> for NativeEndian<u16>
source§impl BitAnd<&NativeEndian<u32>> for &NativeEndian<u32>
impl BitAnd<&NativeEndian<u32>> for &NativeEndian<u32>
source§impl BitAnd<&NativeEndian<u32>> for NativeEndian<u32>
impl BitAnd<&NativeEndian<u32>> for NativeEndian<u32>
source§impl BitAnd<&NativeEndian<u64>> for &NativeEndian<u64>
impl BitAnd<&NativeEndian<u64>> for &NativeEndian<u64>
source§impl BitAnd<&NativeEndian<u64>> for NativeEndian<u64>
impl BitAnd<&NativeEndian<u64>> for NativeEndian<u64>
source§impl BitAnd<&NativeEndian<u128>> for &NativeEndian<u128>
impl BitAnd<&NativeEndian<u128>> for &NativeEndian<u128>
source§impl BitAnd<&NativeEndian<u128>> for NativeEndian<u128>
impl BitAnd<&NativeEndian<u128>> for NativeEndian<u128>
source§impl BitAnd<LittleEndian<i16>> for &LittleEndian<i16>
impl BitAnd<LittleEndian<i16>> for &LittleEndian<i16>
source§impl BitAnd<LittleEndian<i32>> for &LittleEndian<i32>
impl BitAnd<LittleEndian<i32>> for &LittleEndian<i32>
source§impl BitAnd<LittleEndian<i64>> for &LittleEndian<i64>
impl BitAnd<LittleEndian<i64>> for &LittleEndian<i64>
source§impl BitAnd<LittleEndian<i128>> for &LittleEndian<i128>
impl BitAnd<LittleEndian<i128>> for &LittleEndian<i128>
source§impl BitAnd<LittleEndian<u16>> for &LittleEndian<u16>
impl BitAnd<LittleEndian<u16>> for &LittleEndian<u16>
source§impl BitAnd<LittleEndian<u32>> for &LittleEndian<u32>
impl BitAnd<LittleEndian<u32>> for &LittleEndian<u32>
source§impl BitAnd<LittleEndian<u64>> for &LittleEndian<u64>
impl BitAnd<LittleEndian<u64>> for &LittleEndian<u64>
source§impl BitAnd<LittleEndian<u128>> for &LittleEndian<u128>
impl BitAnd<LittleEndian<u128>> for &LittleEndian<u128>
source§impl BitAnd<NativeEndian<i16>> for &NativeEndian<i16>
impl BitAnd<NativeEndian<i16>> for &NativeEndian<i16>
source§impl BitAnd<NativeEndian<i32>> for &NativeEndian<i32>
impl BitAnd<NativeEndian<i32>> for &NativeEndian<i32>
source§impl BitAnd<NativeEndian<i64>> for &NativeEndian<i64>
impl BitAnd<NativeEndian<i64>> for &NativeEndian<i64>
source§impl BitAnd<NativeEndian<i128>> for &NativeEndian<i128>
impl BitAnd<NativeEndian<i128>> for &NativeEndian<i128>
source§impl BitAnd<NativeEndian<u16>> for &NativeEndian<u16>
impl BitAnd<NativeEndian<u16>> for &NativeEndian<u16>
source§impl BitAnd<NativeEndian<u32>> for &NativeEndian<u32>
impl BitAnd<NativeEndian<u32>> for &NativeEndian<u32>
source§impl BitAnd<NativeEndian<u64>> for &NativeEndian<u64>
impl BitAnd<NativeEndian<u64>> for &NativeEndian<u64>
source§impl BitAnd<NativeEndian<u128>> for &NativeEndian<u128>
impl BitAnd<NativeEndian<u128>> for &NativeEndian<u128>
1.74.0 · source§impl<'a> BitAnd<Saturating<i8>> for &'a Saturating<i8>
impl<'a> BitAnd<Saturating<i8>> for &'a Saturating<i8>
1.74.0 · source§impl<'a> BitAnd<Saturating<i16>> for &'a Saturating<i16>
impl<'a> BitAnd<Saturating<i16>> for &'a Saturating<i16>
1.74.0 · source§impl<'a> BitAnd<Saturating<i32>> for &'a Saturating<i32>
impl<'a> BitAnd<Saturating<i32>> for &'a Saturating<i32>
1.74.0 · source§impl<'a> BitAnd<Saturating<i64>> for &'a Saturating<i64>
impl<'a> BitAnd<Saturating<i64>> for &'a Saturating<i64>
1.74.0 · source§impl<'a> BitAnd<Saturating<i128>> for &'a Saturating<i128>
impl<'a> BitAnd<Saturating<i128>> for &'a Saturating<i128>
1.74.0 · source§impl<'a> BitAnd<Saturating<isize>> for &'a Saturating<isize>
impl<'a> BitAnd<Saturating<isize>> for &'a Saturating<isize>
1.74.0 · source§impl<'a> BitAnd<Saturating<u8>> for &'a Saturating<u8>
impl<'a> BitAnd<Saturating<u8>> for &'a Saturating<u8>
1.74.0 · source§impl<'a> BitAnd<Saturating<u16>> for &'a Saturating<u16>
impl<'a> BitAnd<Saturating<u16>> for &'a Saturating<u16>
1.74.0 · source§impl<'a> BitAnd<Saturating<u32>> for &'a Saturating<u32>
impl<'a> BitAnd<Saturating<u32>> for &'a Saturating<u32>
1.74.0 · source§impl<'a> BitAnd<Saturating<u64>> for &'a Saturating<u64>
impl<'a> BitAnd<Saturating<u64>> for &'a Saturating<u64>
1.74.0 · source§impl<'a> BitAnd<Saturating<u128>> for &'a Saturating<u128>
impl<'a> BitAnd<Saturating<u128>> for &'a Saturating<u128>
1.74.0 · source§impl<'a> BitAnd<Saturating<usize>> for &'a Saturating<usize>
impl<'a> BitAnd<Saturating<usize>> for &'a Saturating<usize>
source§impl<O: Into<EnumSet<CpuFeature>>> BitAnd<O> for CpuFeature
impl<O: Into<EnumSet<CpuFeature>>> BitAnd<O> for CpuFeature
type Output = EnumSet<CpuFeature>
source§impl<Ul, Bl, Ur> BitAnd<Ur> for UInt<Ul, Bl>
impl<Ul, Bl, Ur> BitAnd<Ur> for UInt<Ul, Bl>
Anding unsigned integers.
We use our PrivateAnd
operator and then Trim
the output.