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

# core::traits::BitAnd

The bitwise AND operator `&`.

## Signature

```rust theme={null}
pub trait BitAnd
```

## Examples

An implementation of `BitAnd` for a wrapper around `bool`.

```rust theme={null}
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

```rust theme={null}
fn bitand(lhs: T, rhs: T) -> T
```

#### Examples

```rust theme={null}
assert_eq!(true & false, false);
assert_eq!(5_u8 & 1_u8, 1);
assert_eq!(true & true, true);
assert_eq!(5_u8 & 2_u8, 0);
```
