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 I got. Resorting to Deref<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.
We discussed this briefly in the libs-api meeting. This is fine. Since this doesn't affect the stable API (as Boxes with a custom allocator are unstable), this doesn't need to go through FCP.
Proposal
Problem statement
Comparing
Box
s that are allocated by different allocators viaPartialEq
orPartialOrd
is not currently possible.Motivating examples or use cases
PartialEq<Vec<U, A2>> for Vec<T, A1>
.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: https://github.com/rust-lang/rust/pull/112628
Alternatives
Box
s viaDeref<Target = T>
.