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

Implement the Eq trait for Option #3542

Closed
Rubyt0x opened this issue Dec 8, 2022 · 2 comments · Fixed by #5302
Closed

Implement the Eq trait for Option #3542

Rubyt0x opened this issue Dec 8, 2022 · 2 comments · Fixed by #5302
Labels
blocked good first issue Good for newcomers lib: std Standard library

Comments

@Rubyt0x
Copy link
Member

Rubyt0x commented Dec 8, 2022

The Identity implements the Eq trait:

impl core::ops::Eq for Identity {
fn eq(self, other: Self) -> bool {
match (self, other) {
(Identity::Address(address1), Identity::Address(address2)) => address1 == address2,
(Identity::ContractId(asset1), Identity::ContractId(asset2)) => asset1 == asset2,
_ => false,
}
}
}

I would like the same thing to exist for Option so I can compare Options.

@Rubyt0x Rubyt0x added good first issue Good for newcomers lib: std Standard library labels Dec 8, 2022
@mohammadfawaz
Copy link
Contributor

mohammadfawaz commented Dec 8, 2022

Thanks @Rubyt0x. To do this, we need to write

impl<T> core::ops::Eq for Option<T> where T: Eq {
    fn eq(...) -> bool {
        ...
    }
}

which is currently blocked by #1162

@brandonsurh
Copy link
Contributor

I don't believe this is blocked anymore. Will see what I can do.

bitzoic added a commit that referenced this issue Dec 3, 2023
## Description
Closes #3542
Implements the `Eq` trait for `Option`. Also adds tests for the
implementation.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Braqzen <103777923+Braqzen@users.noreply.github.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked good first issue Good for newcomers lib: std Standard library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants