Trait wasmer_types::lib::std::ops::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§

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.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>

§

impl BitAndAssign<&i16> for BigEndian<i16>

§

impl BitAndAssign<&i16> for LittleEndian<i16>

§

impl BitAndAssign<&i16> for NativeEndian<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>

§

impl BitAndAssign<&i32> for BigEndian<i32>

§

impl BitAndAssign<&i32> for LittleEndian<i32>

§

impl BitAndAssign<&i32> for NativeEndian<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>

§

impl BitAndAssign<&i64> for BigEndian<i64>

§

impl BitAndAssign<&i64> for LittleEndian<i64>

§

impl BitAndAssign<&i64> for NativeEndian<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>

§

impl BitAndAssign<&i128> for BigEndian<i128>

§

impl BitAndAssign<&i128> for LittleEndian<i128>

§

impl BitAndAssign<&i128> for NativeEndian<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>

§

impl BitAndAssign<&u16> for BigEndian<u16>

§

impl BitAndAssign<&u16> for LittleEndian<u16>

§

impl BitAndAssign<&u16> for NativeEndian<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>

§

impl BitAndAssign<&u32> for BigEndian<u32>

§

impl BitAndAssign<&u32> for LittleEndian<u32>

§

impl BitAndAssign<&u32> for NativeEndian<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>

§

impl BitAndAssign<&u64> for BigEndian<u64>

§

impl BitAndAssign<&u64> for LittleEndian<u64>

§

impl BitAndAssign<&u64> for NativeEndian<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>

§

impl BitAndAssign<&u128> for BigEndian<u128>

§

impl BitAndAssign<&u128> for LittleEndian<u128>

§

impl BitAndAssign<&u128> for NativeEndian<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.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>

§

impl BitAndAssign<&BigEndian<i16>> for BigEndian<i16>

§

impl BitAndAssign<&BigEndian<i32>> for BigEndian<i32>

§

impl BitAndAssign<&BigEndian<i64>> for BigEndian<i64>

§

impl BitAndAssign<&BigEndian<i128>> for BigEndian<i128>

§

impl BitAndAssign<&BigEndian<u16>> for BigEndian<u16>

§

impl BitAndAssign<&BigEndian<u32>> for BigEndian<u32>

§

impl BitAndAssign<&BigEndian<u64>> for BigEndian<u64>

§

impl BitAndAssign<&BigEndian<u128>> for BigEndian<u128>

§

impl BitAndAssign<&LittleEndian<i16>> for LittleEndian<i16>

§

impl BitAndAssign<&LittleEndian<i32>> for LittleEndian<i32>

§

impl BitAndAssign<&LittleEndian<i64>> for LittleEndian<i64>

§

impl BitAndAssign<&LittleEndian<i128>> for LittleEndian<i128>

§

impl BitAndAssign<&LittleEndian<u16>> for LittleEndian<u16>

§

impl BitAndAssign<&LittleEndian<u32>> for LittleEndian<u32>

§

impl BitAndAssign<&LittleEndian<u64>> for LittleEndian<u64>

§

impl BitAndAssign<&LittleEndian<u128>> for LittleEndian<u128>

§

impl BitAndAssign<&NativeEndian<i16>> for NativeEndian<i16>

§

impl BitAndAssign<&NativeEndian<i32>> for NativeEndian<i32>

§

impl BitAndAssign<&NativeEndian<i64>> for NativeEndian<i64>

§

impl BitAndAssign<&NativeEndian<i128>> for NativeEndian<i128>

§

impl BitAndAssign<&NativeEndian<u16>> for NativeEndian<u16>

§

impl BitAndAssign<&NativeEndian<u32>> for NativeEndian<u32>

§

impl BitAndAssign<&NativeEndian<u64>> for NativeEndian<u64>

§

impl BitAndAssign<&NativeEndian<u128>> for NativeEndian<u128>

source§

impl BitAndAssign<bool> for bool

source§

impl BitAndAssign<i8> for i8

source§

impl BitAndAssign<i8> for Saturating<i8>

1.60.0 · source§

impl BitAndAssign<i8> for Wrapping<i8>

source§

impl BitAndAssign<i16> for i16

source§

impl BitAndAssign<i16> for Saturating<i16>

1.60.0 · source§

impl BitAndAssign<i16> for Wrapping<i16>

§

impl BitAndAssign<i16> for BigEndian<i16>

§

impl BitAndAssign<i16> for LittleEndian<i16>

§

impl BitAndAssign<i16> for NativeEndian<i16>

source§

impl BitAndAssign<i32> for i32

source§

impl BitAndAssign<i32> for Saturating<i32>

1.60.0 · source§

impl BitAndAssign<i32> for Wrapping<i32>

§

impl BitAndAssign<i32> for BigEndian<i32>

§

impl BitAndAssign<i32> for LittleEndian<i32>

§

impl BitAndAssign<i32> for NativeEndian<i32>

source§

impl BitAndAssign<i64> for i64

source§

impl BitAndAssign<i64> for Saturating<i64>

1.60.0 · source§

impl BitAndAssign<i64> for Wrapping<i64>

§

impl BitAndAssign<i64> for BigEndian<i64>

§

impl BitAndAssign<i64> for LittleEndian<i64>

§

impl BitAndAssign<i64> for NativeEndian<i64>

source§

impl BitAndAssign<i128> for i128

source§

impl BitAndAssign<i128> for Saturating<i128>

1.60.0 · source§

impl BitAndAssign<i128> for Wrapping<i128>

§

impl BitAndAssign<i128> for BigEndian<i128>

§

impl BitAndAssign<i128> for LittleEndian<i128>

§

impl BitAndAssign<i128> for NativeEndian<i128>

source§

impl BitAndAssign<isize> for isize

source§

impl BitAndAssign<isize> for Saturating<isize>

1.60.0 · source§

impl BitAndAssign<isize> for Wrapping<isize>

source§

impl BitAndAssign<u8> for u8

source§

impl BitAndAssign<u8> for Saturating<u8>

1.60.0 · source§

impl BitAndAssign<u8> for Wrapping<u8>

source§

impl BitAndAssign<u16> for u16

source§

impl BitAndAssign<u16> for Saturating<u16>

1.60.0 · source§

impl BitAndAssign<u16> for Wrapping<u16>

§

impl BitAndAssign<u16> for BigEndian<u16>

§

impl BitAndAssign<u16> for LittleEndian<u16>

§

impl BitAndAssign<u16> for NativeEndian<u16>

source§

impl BitAndAssign<u32> for u32

source§

impl BitAndAssign<u32> for Saturating<u32>

1.60.0 · source§

impl BitAndAssign<u32> for Wrapping<u32>

§

impl BitAndAssign<u32> for BigEndian<u32>

§

impl BitAndAssign<u32> for LittleEndian<u32>

§

impl BitAndAssign<u32> for NativeEndian<u32>

source§

impl BitAndAssign<u64> for u64

source§

impl BitAndAssign<u64> for Saturating<u64>

1.60.0 · source§

impl BitAndAssign<u64> for Wrapping<u64>

§

impl BitAndAssign<u64> for BigEndian<u64>

§

impl BitAndAssign<u64> for LittleEndian<u64>

§

impl BitAndAssign<u64> for NativeEndian<u64>

source§

impl BitAndAssign<u128> for u128

source§

impl BitAndAssign<u128> for Saturating<u128>

1.60.0 · source§

impl BitAndAssign<u128> for Wrapping<u128>

§

impl BitAndAssign<u128> for BigEndian<u128>

§

impl BitAndAssign<u128> for LittleEndian<u128>

§

impl BitAndAssign<u128> for NativeEndian<u128>

source§

impl BitAndAssign<usize> for usize

source§

impl BitAndAssign<usize> for Saturating<usize>

1.60.0 · source§

impl BitAndAssign<usize> for Wrapping<usize>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

§

impl BitAndAssign<BigEndian<i16>> for BigEndian<i16>

§

impl BitAndAssign<BigEndian<i32>> for BigEndian<i32>

§

impl BitAndAssign<BigEndian<i64>> for BigEndian<i64>

§

impl BitAndAssign<BigEndian<i128>> for BigEndian<i128>

§

impl BitAndAssign<BigEndian<u16>> for BigEndian<u16>

§

impl BitAndAssign<BigEndian<u32>> for BigEndian<u32>

§

impl BitAndAssign<BigEndian<u64>> for BigEndian<u64>

§

impl BitAndAssign<BigEndian<u128>> for BigEndian<u128>

§

impl BitAndAssign<LittleEndian<i16>> for LittleEndian<i16>

§

impl BitAndAssign<LittleEndian<i32>> for LittleEndian<i32>

§

impl BitAndAssign<LittleEndian<i64>> for LittleEndian<i64>

§

impl BitAndAssign<LittleEndian<i128>> for LittleEndian<i128>

§

impl BitAndAssign<LittleEndian<u16>> for LittleEndian<u16>

§

impl BitAndAssign<LittleEndian<u32>> for LittleEndian<u32>

§

impl BitAndAssign<LittleEndian<u64>> for LittleEndian<u64>

§

impl BitAndAssign<LittleEndian<u128>> for LittleEndian<u128>

§

impl BitAndAssign<NativeEndian<i16>> for NativeEndian<i16>

§

impl BitAndAssign<NativeEndian<i32>> for NativeEndian<i32>

§

impl BitAndAssign<NativeEndian<i64>> for NativeEndian<i64>

§

impl BitAndAssign<NativeEndian<i128>> for NativeEndian<i128>

§

impl BitAndAssign<NativeEndian<u16>> for NativeEndian<u16>

§

impl BitAndAssign<NativeEndian<u32>> for NativeEndian<u32>

§

impl BitAndAssign<NativeEndian<u64>> for NativeEndian<u64>

§

impl BitAndAssign<NativeEndian<u128>> for NativeEndian<u128>

source§

impl<T, O> BitAndAssign<O> for EnumSet<T>where T: EnumSetType, O: Into<EnumSet<T>>,

source§

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

source§

impl<T, const LANES: usize> BitAndAssign<bool> for Mask<T, LANES>where T: MaskElement, LaneCount<LANES>: SupportedLaneCount,

source§

impl<T, const LANES: usize> BitAndAssign<Mask<T, LANES>> for Mask<T, LANES>where T: MaskElement, LaneCount<LANES>: SupportedLaneCount,