Trait BitAndAssign

1.8.0 ยท Source
pub trait BitAndAssign<Rhs = Self> {
    // Required method
    fn bitand_assign(&mut self, rhs: Rhs);
}
Expand description

The bitwise AND assignment operator &=.

ยงExamples

An implementation of BitAndAssign that lifts the &= operator to a wrapper around bool.

use std::ops::BitAndAssign;

#[derive(Debug, PartialEq)]
struct Scalar(bool);

impl BitAndAssign for Scalar {
    // rhs is the "right-hand side" of the expression `a &= b`
    fn bitand_assign(&mut self, rhs: Self) {
        *self = Self(self.0 & rhs.0)
    }
}

let mut scalar = Scalar(true);
scalar &= Scalar(true);
assert_eq!(scalar, Scalar(true));

let mut scalar = Scalar(true);
scalar &= Scalar(false);
assert_eq!(scalar, Scalar(false));

let mut scalar = Scalar(false);
scalar &= Scalar(true);
assert_eq!(scalar, Scalar(false));

let mut scalar = Scalar(false);
scalar &= Scalar(false);
assert_eq!(scalar, Scalar(false));

Here, the BitAndAssign trait is implemented for a wrapper around Vec<bool>.

use std::ops::BitAndAssign;

#[derive(Debug, PartialEq)]
struct BooleanVector(Vec<bool>);

impl BitAndAssign for BooleanVector {
    // `rhs` is the "right-hand side" of the expression `a &= b`.
    fn bitand_assign(&mut self, rhs: Self) {
        assert_eq!(self.0.len(), rhs.0.len());
        *self = Self(
            self.0
                .iter()
                .zip(rhs.0.iter())
                .map(|(x, y)| *x & *y)
                .collect()
        );
    }
}

let mut bv = BooleanVector(vec![true, true, false, false]);
bv &= BooleanVector(vec![true, false, true, false]);
let expected = BooleanVector(vec![true, false, false, false]);
assert_eq!(bv, expected);

Required Methodsยง

1.8.0 ยท Source

fn bitand_assign(&mut self, rhs: Rhs)

Performs the &= operation.

ยงExamples
let mut x = true;
x &= false;
assert_eq!(x, false);

let mut x = true;
x &= true;
assert_eq!(x, true);

let mut x: u8 = 5;
x &= 1;
assert_eq!(x, 1);

let mut x: u8 = 5;
x &= 2;
assert_eq!(x, 0);

Implementorsยง

1.8.0 ยท Sourceยง

impl BitAndAssign for bool

1.8.0 ยท Sourceยง

impl BitAndAssign for i8

1.8.0 ยท Sourceยง

impl BitAndAssign for i16

1.8.0 ยท Sourceยง

impl BitAndAssign for i32

1.8.0 ยท Sourceยง

impl BitAndAssign for i64

1.8.0 ยท Sourceยง

impl BitAndAssign for i128

1.8.0 ยท Sourceยง

impl BitAndAssign for isize

1.8.0 ยท Sourceยง

impl BitAndAssign for u8

1.8.0 ยท Sourceยง

impl BitAndAssign for u16

1.8.0 ยท Sourceยง

impl BitAndAssign for u32

1.8.0 ยท Sourceยง

impl BitAndAssign for u64

1.8.0 ยท Sourceยง

impl BitAndAssign for u128

1.8.0 ยท Sourceยง

impl BitAndAssign for usize

1.75.0 ยท Sourceยง

impl BitAndAssign for Ipv4Addr

1.75.0 ยท Sourceยง

impl BitAndAssign for Ipv6Addr

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<i8>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<i16>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<i32>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<i64>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<i128>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<isize>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<u8>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<u16>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<u32>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<u64>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<u128>

1.74.0 ยท Sourceยง

impl BitAndAssign for Saturating<usize>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<i8>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<i16>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<i32>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<i64>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<i128>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<isize>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<u8>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<u16>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<u32>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<u64>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<u128>

1.8.0 ยท Sourceยง

impl BitAndAssign for Wrapping<usize>

Sourceยง

impl BitAndAssign for AttrCheckFlags

Sourceยง

impl BitAndAssign for CheckoutNotificationType

Sourceยง

impl BitAndAssign for CredentialType

Sourceยง

impl BitAndAssign for DiffFlags

Sourceยง

impl BitAndAssign for DiffStatsFormat

Sourceยง

impl BitAndAssign for IndexAddOption

Sourceยง

impl BitAndAssign for IndexEntryExtendedFlag

Sourceยง

impl BitAndAssign for IndexEntryFlag

Sourceยง

impl BitAndAssign for MergeAnalysis

Sourceยง

impl BitAndAssign for MergePreference

Sourceยง

impl BitAndAssign for OdbLookupFlags

Sourceยง

impl BitAndAssign for PathspecFlags

Sourceยง

impl BitAndAssign for ReferenceFormat

Sourceยง

impl BitAndAssign for RemoteUpdateFlags

Sourceยง

impl BitAndAssign for RepositoryInitMode

Sourceยง

impl BitAndAssign for RepositoryOpenFlags

Sourceยง

impl BitAndAssign for RevparseMode

Sourceยง

impl BitAndAssign for Sort

Sourceยง

impl BitAndAssign for StashApplyFlags

Sourceยง

impl BitAndAssign for StashFlags

Sourceยง

impl BitAndAssign for Status

Sourceยง

impl BitAndAssign for SubmoduleStatus

Sourceยง

impl BitAndAssign for CipherCtxFlags

Sourceยง

impl BitAndAssign for CMSOptions

Sourceยง

impl BitAndAssign for OcspFlag

Sourceยง

impl BitAndAssign for Pkcs7Flags

Sourceยง

impl BitAndAssign for ExtensionContext

Sourceยง

impl BitAndAssign for ShutdownState

Sourceยง

impl BitAndAssign for SslMode

Sourceยง

impl BitAndAssign for SslOptions

Sourceยง

impl BitAndAssign for SslSessionCacheMode

Sourceยง

impl BitAndAssign for SslVerifyMode

Sourceยง

impl BitAndAssign for X509CheckFlags

Sourceยง

impl BitAndAssign for X509VerifyFlags

Sourceยง

impl BitAndAssign for Choice

ยง

impl BitAndAssign for Access

ยง

impl BitAndAssign for Access

ยง

impl BitAndAssign for AtFlags

ยง

impl BitAndAssign for AtFlags

ยง

impl BitAndAssign for ChannelType

ยง

impl BitAndAssign for ColorFallbackKind

ยง

impl BitAndAssign for ColorScheme

ยง

impl BitAndAssign for CreateFlags

ยง

impl BitAndAssign for CreateFlags

ยง

impl BitAndAssign for CreateFlags

ยง

impl BitAndAssign for DupFlags

ยง

impl BitAndAssign for DupFlags

ยง

impl BitAndAssign for ElementSelectorFlags

ยง

impl BitAndAssign for EventFlags

ยง

impl BitAndAssign for EventfdFlags

ยง

impl BitAndAssign for FallocateFlags

ยง

impl BitAndAssign for FallocateFlags

ยง

impl BitAndAssign for FdFlags

ยง

impl BitAndAssign for FdFlags

ยง

impl BitAndAssign for Features

ยง

impl BitAndAssign for FloatingPointEmulationControl

ยง

impl BitAndAssign for FloatingPointExceptionMode

ยง

impl BitAndAssign for FmtSpan

ยง

impl BitAndAssign for GridAutoFlow

ยง

impl BitAndAssign for IFlags

ยง

impl BitAndAssign for IFlags

ยง

impl BitAndAssign for MemfdFlags

ยง

impl BitAndAssign for MemfdFlags

ยง

impl BitAndAssign for Mode

ยง

impl BitAndAssign for Mode

ยง

impl BitAndAssign for MountFlags

ยง

impl BitAndAssign for MountPropagationFlags

ยง

impl BitAndAssign for OFlags

ยง

impl BitAndAssign for OFlags

ยง

impl BitAndAssign for ParserFlags

ยง

impl BitAndAssign for PidfdFlags

ยง

impl BitAndAssign for PidfdGetfdFlags

ยง

impl BitAndAssign for PipeFlags

ยง

impl BitAndAssign for PollFlags

ยง

impl BitAndAssign for ReadFlags

ยง

impl BitAndAssign for ReadFlags

ยง

impl BitAndAssign for ReadWriteFlags

ยง

impl BitAndAssign for ReadWriteFlags

ยง

impl BitAndAssign for RecvFlags

ยง

impl BitAndAssign for RenameFlags

ยง

impl BitAndAssign for RenameFlags

ยง

impl BitAndAssign for ResolveFlags

ยง

impl BitAndAssign for ResolveFlags

ยง

impl BitAndAssign for ReturnFlags

ยง

impl BitAndAssign for SealFlags

ยง

impl BitAndAssign for SealFlags

ยง

impl BitAndAssign for SendFlags

ยง

impl BitAndAssign for SocketAddrXdpFlags

ยง

impl BitAndAssign for SocketFlags

ยง

impl BitAndAssign for SpeculationFeatureControl

ยง

impl BitAndAssign for SpeculationFeatureState

ยง

impl BitAndAssign for SpliceFlags

ยง

impl BitAndAssign for StatVfsMountFlags

ยง

impl BitAndAssign for StatVfsMountFlags

ยง

impl BitAndAssign for StatxAttributes

ยง

impl BitAndAssign for StatxFlags

ยง

impl BitAndAssign for StatxFlags

ยง

impl BitAndAssign for TextDecorationLine

ยง

impl BitAndAssign for TextTransformOther

ยง

impl BitAndAssign for TimerfdFlags

ยง

impl BitAndAssign for TimerfdTimerFlags

ยง

impl BitAndAssign for UnalignedAccessControl

ยง

impl BitAndAssign for UnmountFlags

ยง

impl BitAndAssign for VendorPrefix

ยง

impl BitAndAssign for WaitIdOptions

ยง

impl BitAndAssign for WaitOptions

ยง

impl BitAndAssign for WatchFlags

ยง

impl BitAndAssign for WatchFlags

ยง

impl BitAndAssign for XattrFlags

ยง

impl BitAndAssign for XattrFlags

ยง

impl BitAndAssign for XdpDescOptions

ยง

impl BitAndAssign for XdpOptionsFlags

ยง

impl BitAndAssign for XdpRingFlags

ยง

impl BitAndAssign for XdpUmemRegFlags

1.22.0 ยท Sourceยง

impl BitAndAssign<&bool> for bool

1.22.0 ยท Sourceยง

impl BitAndAssign<&i8> for i8

1.22.0 ยท Sourceยง

impl BitAndAssign<&i8> for Saturating<i8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i8> for Wrapping<i8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i16> for i16

1.22.0 ยท Sourceยง

impl BitAndAssign<&i16> for Saturating<i16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i16> for Wrapping<i16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i32> for i32

1.22.0 ยท Sourceยง

impl BitAndAssign<&i32> for Saturating<i32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i32> for Wrapping<i32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i64> for i64

1.22.0 ยท Sourceยง

impl BitAndAssign<&i64> for Saturating<i64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i64> for Wrapping<i64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i128> for i128

1.22.0 ยท Sourceยง

impl BitAndAssign<&i128> for Saturating<i128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&i128> for Wrapping<i128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&isize> for isize

1.22.0 ยท Sourceยง

impl BitAndAssign<&isize> for Saturating<isize>

1.22.0 ยท Sourceยง

impl BitAndAssign<&isize> for Wrapping<isize>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u8> for u8

1.22.0 ยท Sourceยง

impl BitAndAssign<&u8> for Saturating<u8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u8> for Wrapping<u8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u16> for u16

1.22.0 ยท Sourceยง

impl BitAndAssign<&u16> for Saturating<u16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u16> for Wrapping<u16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u32> for u32

1.22.0 ยท Sourceยง

impl BitAndAssign<&u32> for Saturating<u32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u32> for Wrapping<u32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u64> for u64

1.22.0 ยท Sourceยง

impl BitAndAssign<&u64> for Saturating<u64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u64> for Wrapping<u64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u128> for u128

1.22.0 ยท Sourceยง

impl BitAndAssign<&u128> for Saturating<u128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&u128> for Wrapping<u128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&usize> for usize

1.22.0 ยท Sourceยง

impl BitAndAssign<&usize> for Saturating<usize>

1.22.0 ยท Sourceยง

impl BitAndAssign<&usize> for Wrapping<usize>

1.75.0 ยท Sourceยง

impl BitAndAssign<&Ipv4Addr> for Ipv4Addr

1.75.0 ยท Sourceยง

impl BitAndAssign<&Ipv6Addr> for Ipv6Addr

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<i8>> for Saturating<i8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<i16>> for Saturating<i16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<i32>> for Saturating<i32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<i64>> for Saturating<i64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<i128>> for Saturating<i128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<isize>> for Saturating<isize>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<u8>> for Saturating<u8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<u16>> for Saturating<u16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<u32>> for Saturating<u32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<u64>> for Saturating<u64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<u128>> for Saturating<u128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Saturating<usize>> for Saturating<usize>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<i8>> for Wrapping<i8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<i16>> for Wrapping<i16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<i32>> for Wrapping<i32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<i64>> for Wrapping<i64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<i128>> for Wrapping<i128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<isize>> for Wrapping<isize>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<u8>> for Wrapping<u8>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<u16>> for Wrapping<u16>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<u32>> for Wrapping<u32>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<u64>> for Wrapping<u64>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<u128>> for Wrapping<u128>

1.22.0 ยท Sourceยง

impl BitAndAssign<&Wrapping<usize>> for Wrapping<usize>

1.74.0 ยท Sourceยง

impl BitAndAssign<i8> for Saturating<i8>

1.60.0 ยท Sourceยง

impl BitAndAssign<i8> for Wrapping<i8>

1.74.0 ยท Sourceยง

impl BitAndAssign<i16> for Saturating<i16>

1.60.0 ยท Sourceยง

impl BitAndAssign<i16> for Wrapping<i16>

1.74.0 ยท Sourceยง

impl BitAndAssign<i32> for Saturating<i32>

1.60.0 ยท Sourceยง

impl BitAndAssign<i32> for Wrapping<i32>

1.74.0 ยท Sourceยง

impl BitAndAssign<i64> for Saturating<i64>

1.60.0 ยท Sourceยง

impl BitAndAssign<i64> for Wrapping<i64>

1.74.0 ยท Sourceยง

impl BitAndAssign<i128> for Saturating<i128>

1.60.0 ยท Sourceยง

impl BitAndAssign<i128> for Wrapping<i128>

1.74.0 ยท Sourceยง

impl BitAndAssign<isize> for Saturating<isize>

1.60.0 ยท Sourceยง

impl BitAndAssign<isize> for Wrapping<isize>

1.74.0 ยท Sourceยง

impl BitAndAssign<u8> for Saturating<u8>

1.60.0 ยท Sourceยง

impl BitAndAssign<u8> for Wrapping<u8>

1.74.0 ยท Sourceยง

impl BitAndAssign<u16> for Saturating<u16>

1.60.0 ยท Sourceยง

impl BitAndAssign<u16> for Wrapping<u16>

1.74.0 ยท Sourceยง

impl BitAndAssign<u32> for Saturating<u32>

1.60.0 ยท Sourceยง

impl BitAndAssign<u32> for Wrapping<u32>

1.74.0 ยท Sourceยง

impl BitAndAssign<u64> for Saturating<u64>

1.60.0 ยท Sourceยง

impl BitAndAssign<u64> for Wrapping<u64>

1.74.0 ยท Sourceยง

impl BitAndAssign<u128> for Saturating<u128>

1.60.0 ยท Sourceยง

impl BitAndAssign<u128> for Wrapping<u128>

1.74.0 ยท Sourceยง

impl BitAndAssign<usize> for Saturating<usize>

1.60.0 ยท Sourceยง

impl BitAndAssign<usize> for Wrapping<usize>

ยง

impl<O> BitAndAssign for I16<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for I32<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for I64<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for I128<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for Isize<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for U16<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for U32<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for U64<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for U128<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign for Usize<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<i16> for I16<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<i32> for I32<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<i64> for I64<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<i128> for I128<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<isize> for Isize<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<u16> for U16<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<u32> for U32<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<u64> for U64<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<u128> for U128<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<usize> for Usize<O>
where O: ByteOrder,

ยง

impl<O> BitAndAssign<I16<O>> for i16
where O: ByteOrder,

ยง

impl<O> BitAndAssign<I32<O>> for i32
where O: ByteOrder,

ยง

impl<O> BitAndAssign<I64<O>> for i64
where O: ByteOrder,

ยง

impl<O> BitAndAssign<I128<O>> for i128
where O: ByteOrder,

ยง

impl<O> BitAndAssign<Isize<O>> for isize
where O: ByteOrder,

ยง

impl<O> BitAndAssign<U16<O>> for u16
where O: ByteOrder,

ยง

impl<O> BitAndAssign<U32<O>> for u32
where O: ByteOrder,

ยง

impl<O> BitAndAssign<U64<O>> for u64
where O: ByteOrder,

ยง

impl<O> BitAndAssign<U128<O>> for u128
where O: ByteOrder,

ยง

impl<O> BitAndAssign<Usize<O>> for usize
where O: ByteOrder,

ยง

impl<T, S, A> BitAndAssign<&HashSet<T, S, A>> for HashSet<T, S, A>
where T: Eq + Hash + Clone, S: BuildHasher, A: Allocator,

Sourceยง

impl<T, U, const N: usize> BitAndAssign<U> for Simd<T, N>
where Simd<T, N>: BitAnd<U, Output = Simd<T, N>>, T: SimdElement, LaneCount<N>: SupportedLaneCount,

Sourceยง

impl<T, const N: usize> BitAndAssign for Mask<T, N>

Sourceยง

impl<T, const N: usize> BitAndAssign<bool> for Mask<T, N>