Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PartialEq for 2,3,4-tuples #3556

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions corelib/src/traits.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,60 @@ impl TupleSize1PartialEq<E0, impl E0PartialEq: PartialEq<E0>> of PartialEq<(E0,
!(rhs == lhs)
}
}

impl TupleSize2PartialEq<
E0, E1, impl E0PartialEq: PartialEq<E0>, impl E1PartialEq: PartialEq<E1>
> of PartialEq<(E0, E1)> {
#[inline(always)]
fn eq(lhs: @(E0, E1), rhs: @(E0, E1)) -> bool {
let (lhs0, lhs1) = lhs;
let (rhs0, rhs1) = rhs;
lhs0 == rhs0 && lhs1 == rhs1
}
#[inline(always)]
fn ne(lhs: @(E0, E1), rhs: @(E0, E1)) -> bool {
!(rhs == lhs)
}
}

impl TupleSize3PartialEq<
E0,
E1,
E2,
impl E0PartialEq: PartialEq<E0>,
impl E1PartialEq: PartialEq<E1>,
impl E2PartialEq: PartialEq<E2>
> of PartialEq<(E0, E1, E2)> {
#[inline(always)]
fn eq(lhs: @(E0, E1, E2), rhs: @(E0, E1, E2)) -> bool {
let (lhs0, lhs1, lhs2) = lhs;
let (rhs0, rhs1, rhs2) = rhs;
lhs0 == rhs0 && lhs1 == rhs1 && lhs2 == rhs2
}
#[inline(always)]
fn ne(lhs: @(E0, E1, E2), rhs: @(E0, E1, E2)) -> bool {
!(rhs == lhs)
}
}

impl TupleSize4PartialEq<
E0,
E1,
E2,
E3,
impl E0PartialEq: PartialEq<E0>,
impl E1PartialEq: PartialEq<E1>,
impl E2PartialEq: PartialEq<E2>,
impl E3PartialEq: PartialEq<E3>
> of PartialEq<(E0, E1, E2, E3)> {
#[inline(always)]
fn eq(lhs: @(E0, E1, E2, E3), rhs: @(E0, E1, E2, E3)) -> bool {
let (lhs0, lhs1, lhs2, lhs3) = lhs;
let (rhs0, rhs1, rhs2, rhs3) = rhs;
lhs0 == rhs0 && lhs1 == rhs1 && lhs2 == rhs2 && lhs3 == rhs3
}
#[inline(always)]
fn ne(lhs: @(E0, E1, E2, E3), rhs: @(E0, E1, E2, E3)) -> bool {
!(rhs == lhs)
}
}