> ## 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::PartialEq

Trait for comparisons using the equality operator.
Implementing this trait for types provides the `==` and `!=` operators for
those types.

This trait can be used with `#[derive]`. When `derive`d on structs, two
instances are equal if all fields are equal, and not equal if any fields
are not equal. When `derive`d on enums, two instances are equal if they
are the same variant and all fields are equal.

## Signature

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

## Examples

An example in which two points are equal if their x and y coordinates are equal.

```rust theme={null}
#[derive(Copy, Drop)]
struct Point {
    x: u32,
    y: u32
}

impl PointEq of PartialEq {
    fn eq(lhs: @Point, rhs: @Point) -> bool {
        lhs.x == rhs.x && lhs.y == rhs.y
    }
}

let p1 = Point { x: 1, y: 2 };
let p2 = Point { x: 1, y: 2 };
assert!(p1 == p2);
assert!(!(p1 != p2));
```

## Trait functions

### eq

Returns whether `lhs` and `rhs` equal, and is used by `==`.

#### Signature

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

#### Examples

```rust theme={null}
assert!(1 == 1);
```

### ne

Returns whether `lhs` and `rhs` are not equal, and is used by `!=`.

#### Signature

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

#### Examples

```rust theme={null}
assert!(0 != 1);
```
