Closed
Description
Proposal
Problem statement
Comparing Box
s that are allocated by different allocators via PartialEq
or PartialOrd
is not currently possible.
Motivating examples or use cases
- It is consistent with
PartialEq<Vec<U, A2>> for Vec<T, A1>
. - I'm writing a library that uses a specific allocator internally. For tests, I'd like to be able to declaratively define data that is
expected
, and compare it with data that Igot
. Resorting toDeref<Target = T>
and comparing individual fields may be very tedious in cases when the data in question contains several layers of types internally, and especially enums.
Solution sketch
See PR: rust-lang/rust#112628
Alternatives
- Compare
Box
s viaDeref<Target = T>
. - Make sure to use the same allocator everywhere.