Skip to content

Make Box comparisons independent of allocator choice #241

Closed
@gootorov

Description

@gootorov

Proposal

Problem statement

Comparing Boxs 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 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.

Solution sketch

See PR: rust-lang/rust#112628

Alternatives

  • Compare Boxs via Deref<Target = T>.
  • Make sure to use the same allocator everywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions