&.
Signature
Examples
An implementation ofBitAnd for a wrapper around bool.
Trait functions
bitand
Performs the& operation.
&.
pub trait BitAnd
BitAnd for a wrapper around bool.
use core::traits::BitAnd;
#[derive(Drop, PartialEq)]
struct Scalar {
inner: bool,
}
impl BitAndScalar of BitAnd {
fn bitand(lhs: Scalar, rhs: Scalar) -> Scalar {
Scalar { inner: lhs.inner & rhs.inner }
}
}
assert!(Scalar { inner: true } & Scalar { inner: true } == Scalar { inner: true });
assert!(Scalar { inner: true } & Scalar { inner: false } == Scalar { inner: false });
assert!(Scalar { inner: false } & Scalar { inner: true } == Scalar { inner: false });
assert!(Scalar { inner: false } & Scalar { inner: false } == Scalar { inner: false });
& operation.
fn bitand(lhs: T, rhs: T) -> T
assert_eq!(true & false, false);
assert_eq!(5_u8 & 1_u8, 1);
assert_eq!(true & true, true);
assert_eq!(5_u8 & 2_u8, 0);
Was this page helpful?