BitAndAssign

Trait BitAndAssign 

1.8.0 (const: unstable) · 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 (const: unstable) · Source§

impl BitAndAssign for bool

1.8.0 (const: unstable) · Source§

impl BitAndAssign for i8

1.8.0 (const: unstable) · Source§

impl BitAndAssign for i16

1.8.0 (const: unstable) · Source§

impl BitAndAssign for i32

1.8.0 (const: unstable) · Source§

impl BitAndAssign for i64

1.8.0 (const: unstable) · Source§

impl BitAndAssign for i128

1.8.0 (const: unstable) · Source§

impl BitAndAssign for isize

1.8.0 (const: unstable) · Source§

impl BitAndAssign for u8

1.8.0 (const: unstable) · Source§

impl BitAndAssign for u16

1.8.0 (const: unstable) · Source§

impl BitAndAssign for u32

1.8.0 (const: unstable) · Source§

impl BitAndAssign for u64

1.8.0 (const: unstable) · Source§

impl BitAndAssign for u128

1.8.0 (const: unstable) · Source§

impl BitAndAssign for usize

1.75.0 (const: unstable) · Source§

impl BitAndAssign for Ipv4Addr

1.75.0 (const: unstable) · Source§

impl BitAndAssign for Ipv6Addr

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<i8>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<i16>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<i32>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<i64>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<i128>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<isize>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<u8>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<u16>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<u32>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<u64>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<u128>

1.74.0 (const: unstable) · Source§

impl BitAndAssign for Saturating<usize>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<i8>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<i16>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<i32>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<i64>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<i128>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<isize>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<u8>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<u16>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<u32>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<u64>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<u128>

1.8.0 (const: unstable) · Source§

impl BitAndAssign for datex_core::without_std::num::Wrapping<usize>

Source§

impl BitAndAssign for AtFlags

Source§

impl BitAndAssign for FallocateFlags

Source§

impl BitAndAssign for FdFlag

Source§

impl BitAndAssign for OFlag

Source§

impl BitAndAssign for RenameFlags

Source§

impl BitAndAssign for SealFlag

Source§

impl BitAndAssign for SpliceFFlags

Source§

impl BitAndAssign for DeleteModuleFlags

Source§

impl BitAndAssign for ModuleInitFlags

Source§

impl BitAndAssign for MntFlags

Source§

impl BitAndAssign for nix::mount::linux::MsFlags

Source§

impl BitAndAssign for MQ_OFlag

Source§

impl BitAndAssign for InterfaceFlags

Source§

impl BitAndAssign for PollFlags

Source§

impl BitAndAssign for CloneFlags

Source§

impl BitAndAssign for EpollCreateFlags

Source§

impl BitAndAssign for EpollFlags

Source§

impl BitAndAssign for EfdFlags

Source§

impl BitAndAssign for AddWatchFlags

Source§

impl BitAndAssign for InitFlags

Source§

impl BitAndAssign for MemFdCreateFlag

Source§

impl BitAndAssign for MRemapFlags

Source§

impl BitAndAssign for MapFlags

Source§

impl BitAndAssign for MlockAllFlags

Source§

impl BitAndAssign for nix::sys::mman::MsFlags

Source§

impl BitAndAssign for ProtFlags

Source§

impl BitAndAssign for Persona

Source§

impl BitAndAssign for Options

Source§

impl BitAndAssign for QuotaValidFlags

Source§

impl BitAndAssign for SaFlags

Source§

impl BitAndAssign for SfdFlags

Source§

impl BitAndAssign for MsgFlags

Source§

impl BitAndAssign for SockFlag

Source§

impl BitAndAssign for TimestampingFlag

Source§

impl BitAndAssign for Mode

Source§

impl BitAndAssign for SFlag

Source§

impl BitAndAssign for FsFlags

Source§

impl BitAndAssign for ControlFlags

Source§

impl BitAndAssign for InputFlags

Source§

impl BitAndAssign for LocalFlags

Source§

impl BitAndAssign for OutputFlags

Source§

impl BitAndAssign for TimerSetTimeFlags

Source§

impl BitAndAssign for TimerFlags

Source§

impl BitAndAssign for WaitPidFlag

Source§

impl BitAndAssign for AccessFlags

Source§

impl BitAndAssign for BigInt

Source§

impl BitAndAssign for BigUint

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

Source§

impl BitAndAssign for FontStyle

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&bool> for bool

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i8> for i8

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&i8> for Saturating<i8>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i8> for datex_core::without_std::num::Wrapping<i8>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i16> for i16

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&i16> for Saturating<i16>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i16> for datex_core::without_std::num::Wrapping<i16>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i32> for i32

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&i32> for Saturating<i32>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i32> for datex_core::without_std::num::Wrapping<i32>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i64> for i64

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&i64> for Saturating<i64>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i64> for datex_core::without_std::num::Wrapping<i64>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i128> for i128

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&i128> for Saturating<i128>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&i128> for datex_core::without_std::num::Wrapping<i128>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&isize> for isize

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&isize> for Saturating<isize>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&isize> for datex_core::without_std::num::Wrapping<isize>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u8> for u8

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&u8> for Saturating<u8>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u8> for datex_core::without_std::num::Wrapping<u8>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u16> for u16

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&u16> for Saturating<u16>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u16> for datex_core::without_std::num::Wrapping<u16>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u32> for u32

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&u32> for Saturating<u32>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u32> for datex_core::without_std::num::Wrapping<u32>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u64> for u64

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&u64> for Saturating<u64>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u64> for datex_core::without_std::num::Wrapping<u64>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u128> for u128

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&u128> for Saturating<u128>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&u128> for datex_core::without_std::num::Wrapping<u128>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&usize> for usize

1.74.0 (const: unstable) · Source§

impl BitAndAssign<&usize> for Saturating<usize>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&usize> for datex_core::without_std::num::Wrapping<usize>

1.75.0 (const: unstable) · Source§

impl BitAndAssign<&Ipv4Addr> for Ipv4Addr

1.75.0 (const: unstable) · Source§

impl BitAndAssign<&Ipv6Addr> for Ipv6Addr

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.74.0 (const: unstable) · Source§

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

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<i8>> for datex_core::without_std::num::Wrapping<i8>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<i16>> for datex_core::without_std::num::Wrapping<i16>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<i32>> for datex_core::without_std::num::Wrapping<i32>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<i64>> for datex_core::without_std::num::Wrapping<i64>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<i128>> for datex_core::without_std::num::Wrapping<i128>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<isize>> for datex_core::without_std::num::Wrapping<isize>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<u8>> for datex_core::without_std::num::Wrapping<u8>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<u16>> for datex_core::without_std::num::Wrapping<u16>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<u32>> for datex_core::without_std::num::Wrapping<u32>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<u64>> for datex_core::without_std::num::Wrapping<u64>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<u128>> for datex_core::without_std::num::Wrapping<u128>

1.22.0 (const: unstable) · Source§

impl BitAndAssign<&Wrapping<usize>> for datex_core::without_std::num::Wrapping<usize>

Source§

impl BitAndAssign<&BigInt> for BigInt

Source§

impl BitAndAssign<&BigUint> for BigUint

1.74.0 (const: unstable) · Source§

impl BitAndAssign<i8> for Saturating<i8>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<i8> for datex_core::without_std::num::Wrapping<i8>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<i16> for Saturating<i16>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<i16> for datex_core::without_std::num::Wrapping<i16>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<i32> for Saturating<i32>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<i32> for datex_core::without_std::num::Wrapping<i32>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<i64> for Saturating<i64>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<i64> for datex_core::without_std::num::Wrapping<i64>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<i128> for Saturating<i128>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<i128> for datex_core::without_std::num::Wrapping<i128>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<isize> for Saturating<isize>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<isize> for datex_core::without_std::num::Wrapping<isize>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<u8> for Saturating<u8>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<u8> for datex_core::without_std::num::Wrapping<u8>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<u16> for Saturating<u16>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<u16> for datex_core::without_std::num::Wrapping<u16>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<u32> for Saturating<u32>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<u32> for datex_core::without_std::num::Wrapping<u32>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<u64> for Saturating<u64>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<u64> for datex_core::without_std::num::Wrapping<u64>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<u128> for Saturating<u128>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<u128> for datex_core::without_std::num::Wrapping<u128>

1.74.0 (const: unstable) · Source§

impl BitAndAssign<usize> for Saturating<usize>

1.60.0 (const: unstable) · Source§

impl BitAndAssign<usize> for datex_core::without_std::num::Wrapping<usize>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T, S, A> BitAndAssign<&HashSet<T, S, A>> for hashbrown::set::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>

Source§

impl<const LIMBS: usize> BitAndAssign for Uint<LIMBS>

Source§

impl<const LIMBS: usize> BitAndAssign for crypto_bigint::wrapping::Wrapping<Uint<LIMBS>>

Source§

impl<const LIMBS: usize> BitAndAssign<&Uint<LIMBS>> for Uint<LIMBS>

Source§

impl<const LIMBS: usize> BitAndAssign<&Wrapping<Uint<LIMBS>>> for crypto_bigint::wrapping::Wrapping<Uint<LIMBS>>