Skip to content

impl PartialEq for Option forces both sides to contain the same T #56598

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

Closed
nagisa opened this issue Dec 7, 2018 · 2 comments
Closed

impl PartialEq for Option forces both sides to contain the same T #56598

nagisa opened this issue Dec 7, 2018 · 2 comments

Comments

@nagisa
Copy link
Member

nagisa commented Dec 7, 2018

The current impl PartialEq for Option looks like this:

impl<T> PartialEq<Option<T>> for Option<T> where
    T: PartialEq<T> { ... }

It could be more general and look like this instead:

impl<A, B> PartialEq<Option<A>> for Option<B> where
    A: PartialEq<B> { ... }
@nagisa
Copy link
Member Author

nagisa commented Dec 7, 2018

Specific use-case where I wanted this to work was:

if path.file_stem() == Some("foo") { ... }

@ollie27
Copy link
Member

ollie27 commented Dec 7, 2018

Duplicate of #20063?

@nagisa nagisa closed this as completed Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants