You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
impl<T> PartialEq<Option<T>> for Option<T> where
T: PartialEq<T>
impl<T, E> PartialEq<Result<T, E>> for Result<T, E> where
E: PartialEq<E>,
T: PartialEq<T>,
desired implementation:
impl<A, B> PartialEq<Option<B>> for Option<A> where
A: PartialEq<B>
impl<TA, TB, EA, EB> PartialEq<Result<TB, EB>> for Result<TA, EA> where
EA: PartialEq<EB>,
TA: PartialEq<TB>,
This would allow nested types that can be compared to be compared without mapping over the structure. I have a particularly painful usecase in sled, where I return a special zero-copy read pointer for some operations that allows me to avoid clones of requested buffers without using an Arc. This pointer type implements PartialEq<T> where T: AsRef<[u8]> so it can be compared against vectors, slices, etc... But the database returns responses to requests as something like Result<Option<ZeroCopyPointer>> which really makes it cumbersome to do things like assert!(Ok(Some(zcp)) == Ok(Some(vec![1,2,3,4]))).
I see a little discussion of something similar at #20927, but it's not totally clear to me based on that if this change would be out of the question due to possible backwards-compatibility concerns.
Is there a major reason why this is impossible with today's rust? I'm happy to implement it if not.
The text was updated successfully, but these errors were encountered:
current implementation:
desired implementation:
This would allow nested types that can be compared to be compared without mapping over the structure. I have a particularly painful usecase in sled, where I return a special zero-copy read pointer for some operations that allows me to avoid clones of requested buffers without using an Arc. This pointer type implements
PartialEq<T>
whereT: AsRef<[u8]>
so it can be compared against vectors, slices, etc... But the database returns responses to requests as something likeResult<Option<ZeroCopyPointer>>
which really makes it cumbersome to do things likeassert!(Ok(Some(zcp)) == Ok(Some(vec![1,2,3,4])))
.I see a little discussion of something similar at #20927, but it's not totally clear to me based on that if this change would be out of the question due to possible backwards-compatibility concerns.
Is there a major reason why this is impossible with today's rust? I'm happy to implement it if not.
The text was updated successfully, but these errors were encountered: