Skip to content

Heterogeneous comparisons for Option #917

Closed
@petrochenkov

Description

@petrochenkov

It would be useful to be able to compare Option<T> with Option<U> if T and U are comparable themselves. I.e.

impl<A, B> PartialEq<Option<B>> for Option<A> where A: PartialEq<B> { ... }

assert!(Some(String::from_str("str")) == Some("str"))

Heterogeneous comparisons for Option are clear and unambiguous and there are precedents - some other basic library types, like Vec or [T] support heterogeneous comparisons too.

cc @aturon
cc rust-lang/rust#22838

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions