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 · Sourcefn bitand_assign(&mut self, rhs: Rhs)
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§
impl BitAndAssign for bool
impl BitAndAssign for i8
impl BitAndAssign for i16
impl BitAndAssign for i32
impl BitAndAssign for i64
impl BitAndAssign for i128
impl BitAndAssign for isize
impl BitAndAssign for u8
impl BitAndAssign for u16
impl BitAndAssign for u32
impl BitAndAssign for u64
impl BitAndAssign for u128
impl BitAndAssign for usize
impl BitAndAssign for Saturating<i8>
impl BitAndAssign for Saturating<i16>
impl BitAndAssign for Saturating<i32>
impl BitAndAssign for Saturating<i64>
impl BitAndAssign for Saturating<i128>
impl BitAndAssign for Saturating<isize>
impl BitAndAssign for Saturating<u8>
impl BitAndAssign for Saturating<u16>
impl BitAndAssign for Saturating<u32>
impl BitAndAssign for Saturating<u64>
impl BitAndAssign for Saturating<u128>
impl BitAndAssign for Saturating<usize>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<i8>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<i16>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<i32>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<i64>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<i128>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<isize>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<u8>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<u16>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<u32>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<u64>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<u128>
impl BitAndAssign for cairo_vm::with_std::num::Wrapping<usize>
impl BitAndAssign for Ipv4Addr
impl BitAndAssign for Ipv6Addr
impl BitAndAssign for BigInt
impl BitAndAssign for BigUint
impl BitAndAssign for udouble
impl BitAndAssign for Choice
impl BitAndAssign<&bool> for bool
impl BitAndAssign<&i8> for i8
impl BitAndAssign<&i8> for Saturating<i8>
impl BitAndAssign<&i8> for cairo_vm::with_std::num::Wrapping<i8>
impl BitAndAssign<&i16> for i16
impl BitAndAssign<&i16> for Saturating<i16>
impl BitAndAssign<&i16> for cairo_vm::with_std::num::Wrapping<i16>
impl BitAndAssign<&i32> for i32
impl BitAndAssign<&i32> for Saturating<i32>
impl BitAndAssign<&i32> for cairo_vm::with_std::num::Wrapping<i32>
impl BitAndAssign<&i64> for i64
impl BitAndAssign<&i64> for Saturating<i64>
impl BitAndAssign<&i64> for cairo_vm::with_std::num::Wrapping<i64>
impl BitAndAssign<&i128> for i128
impl BitAndAssign<&i128> for Saturating<i128>
impl BitAndAssign<&i128> for cairo_vm::with_std::num::Wrapping<i128>
impl BitAndAssign<&isize> for isize
impl BitAndAssign<&isize> for Saturating<isize>
impl BitAndAssign<&isize> for cairo_vm::with_std::num::Wrapping<isize>
impl BitAndAssign<&u8> for u8
impl BitAndAssign<&u8> for Saturating<u8>
impl BitAndAssign<&u8> for cairo_vm::with_std::num::Wrapping<u8>
impl BitAndAssign<&u16> for u16
impl BitAndAssign<&u16> for Saturating<u16>
impl BitAndAssign<&u16> for cairo_vm::with_std::num::Wrapping<u16>
impl BitAndAssign<&u32> for u32
impl BitAndAssign<&u32> for Saturating<u32>
impl BitAndAssign<&u32> for cairo_vm::with_std::num::Wrapping<u32>
impl BitAndAssign<&u64> for u64
impl BitAndAssign<&u64> for Saturating<u64>
impl BitAndAssign<&u64> for cairo_vm::with_std::num::Wrapping<u64>
impl BitAndAssign<&u128> for u128
impl BitAndAssign<&u128> for Saturating<u128>
impl BitAndAssign<&u128> for cairo_vm::with_std::num::Wrapping<u128>
impl BitAndAssign<&usize> for usize
impl BitAndAssign<&usize> for Saturating<usize>
impl BitAndAssign<&usize> for cairo_vm::with_std::num::Wrapping<usize>
impl BitAndAssign<&Saturating<i8>> for Saturating<i8>
impl BitAndAssign<&Saturating<i16>> for Saturating<i16>
impl BitAndAssign<&Saturating<i32>> for Saturating<i32>
impl BitAndAssign<&Saturating<i64>> for Saturating<i64>
impl BitAndAssign<&Saturating<i128>> for Saturating<i128>
impl BitAndAssign<&Saturating<isize>> for Saturating<isize>
impl BitAndAssign<&Saturating<u8>> for Saturating<u8>
impl BitAndAssign<&Saturating<u16>> for Saturating<u16>
impl BitAndAssign<&Saturating<u32>> for Saturating<u32>
impl BitAndAssign<&Saturating<u64>> for Saturating<u64>
impl BitAndAssign<&Saturating<u128>> for Saturating<u128>
impl BitAndAssign<&Saturating<usize>> for Saturating<usize>
impl BitAndAssign<&Wrapping<i8>> for cairo_vm::with_std::num::Wrapping<i8>
impl BitAndAssign<&Wrapping<i16>> for cairo_vm::with_std::num::Wrapping<i16>
impl BitAndAssign<&Wrapping<i32>> for cairo_vm::with_std::num::Wrapping<i32>
impl BitAndAssign<&Wrapping<i64>> for cairo_vm::with_std::num::Wrapping<i64>
impl BitAndAssign<&Wrapping<i128>> for cairo_vm::with_std::num::Wrapping<i128>
impl BitAndAssign<&Wrapping<isize>> for cairo_vm::with_std::num::Wrapping<isize>
impl BitAndAssign<&Wrapping<u8>> for cairo_vm::with_std::num::Wrapping<u8>
impl BitAndAssign<&Wrapping<u16>> for cairo_vm::with_std::num::Wrapping<u16>
impl BitAndAssign<&Wrapping<u32>> for cairo_vm::with_std::num::Wrapping<u32>
impl BitAndAssign<&Wrapping<u64>> for cairo_vm::with_std::num::Wrapping<u64>
impl BitAndAssign<&Wrapping<u128>> for cairo_vm::with_std::num::Wrapping<u128>
impl BitAndAssign<&Wrapping<usize>> for cairo_vm::with_std::num::Wrapping<usize>
impl BitAndAssign<&Ipv4Addr> for Ipv4Addr
impl BitAndAssign<&Ipv6Addr> for Ipv6Addr
impl BitAndAssign<&BigInt> for BigInt
impl BitAndAssign<&BigUint> for BigUint
impl BitAndAssign<i8> for Saturating<i8>
impl BitAndAssign<i8> for cairo_vm::with_std::num::Wrapping<i8>
impl BitAndAssign<i16> for Saturating<i16>
impl BitAndAssign<i16> for cairo_vm::with_std::num::Wrapping<i16>
impl BitAndAssign<i32> for Saturating<i32>
impl BitAndAssign<i32> for cairo_vm::with_std::num::Wrapping<i32>
impl BitAndAssign<i64> for Saturating<i64>
impl BitAndAssign<i64> for cairo_vm::with_std::num::Wrapping<i64>
impl BitAndAssign<i128> for Saturating<i128>
impl BitAndAssign<i128> for cairo_vm::with_std::num::Wrapping<i128>
impl BitAndAssign<isize> for Saturating<isize>
impl BitAndAssign<isize> for cairo_vm::with_std::num::Wrapping<isize>
impl BitAndAssign<u8> for Saturating<u8>
impl BitAndAssign<u8> for cairo_vm::with_std::num::Wrapping<u8>
impl BitAndAssign<u16> for Saturating<u16>
impl BitAndAssign<u16> for cairo_vm::with_std::num::Wrapping<u16>
impl BitAndAssign<u32> for Saturating<u32>
impl BitAndAssign<u32> for cairo_vm::with_std::num::Wrapping<u32>
impl BitAndAssign<u64> for Saturating<u64>
impl BitAndAssign<u64> for cairo_vm::with_std::num::Wrapping<u64>
impl BitAndAssign<u128> for Saturating<u128>
impl BitAndAssign<u128> for cairo_vm::with_std::num::Wrapping<u128>
impl BitAndAssign<usize> for Saturating<usize>
impl BitAndAssign<usize> for cairo_vm::with_std::num::Wrapping<usize>
impl<A, O> BitAndAssign<&BitArray<A, O>> for BitSlice<<A as BitView>::Store, O>where
A: BitViewSized,
O: BitOrder,
Available on non-
tarpaulin_include only.impl<A, O> BitAndAssign<BitArray<A, O>> for BitSlice<<A as BitView>::Store, O>where
A: BitViewSized,
O: BitOrder,
Available on non-
tarpaulin_include only.impl<A, O, Rhs> BitAndAssign<Rhs> for BitArray<A, O>
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 i16where
O: ByteOrder,
impl<O> BitAndAssign<I32<O>> for i32where
O: ByteOrder,
impl<O> BitAndAssign<I64<O>> for i64where
O: ByteOrder,
impl<O> BitAndAssign<I128<O>> for i128where
O: ByteOrder,
impl<O> BitAndAssign<Isize<O>> for isizewhere
O: ByteOrder,
impl<O> BitAndAssign<U16<O>> for u16where
O: ByteOrder,
impl<O> BitAndAssign<U32<O>> for u32where
O: ByteOrder,
impl<O> BitAndAssign<U64<O>> for u64where
O: ByteOrder,
impl<O> BitAndAssign<U128<O>> for u128where
O: ByteOrder,
impl<O> BitAndAssign<Usize<O>> for usizewhere
O: ByteOrder,
impl<T1, T2, O1, O2> BitAndAssign<&BitSlice<T2, O2>> for BitSlice<T1, O1>
impl<T, O> BitAndAssign<&BitBox<T, O>> for BitSlice<T, O>
Available on non-
tarpaulin_include only.impl<T, O> BitAndAssign<&BitVec<T, O>> for BitSlice<T, O>
Available on non-
tarpaulin_include only.impl<T, O> BitAndAssign<BitBox<T, O>> for BitSlice<T, O>
Available on non-
tarpaulin_include only.impl<T, O> BitAndAssign<BitVec<T, O>> for BitSlice<T, O>
Available on non-
tarpaulin_include only.impl<T, O, Rhs> BitAndAssign<Rhs> for BitBox<T, O>
impl<T, O, Rhs> BitAndAssign<Rhs> for BitVec<T, O>
Available on non-
tarpaulin_include only.