Documentation Index
Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
Use this file to discover all available pages before exploring further.
The bitwise AND operator &.
Signature
Examples
An implementation of 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 });
Trait functions
bitand
Performs the & operation.
Signature
fn bitand(lhs: T, rhs: T) -> T
Examples
assert_eq!(true & false, false);
assert_eq!(5_u8 & 1_u8, 1);
assert_eq!(true & true, true);
assert_eq!(5_u8 & 2_u8, 0);