Skip to content

Allocator equality #109

Open
Open
@Amanieu

Description

@Amanieu

rust-lang/rust#103093 (comment) brought up an interesting use case for testing whether two allocator instances of the same type are compatible. This came up in the context of appending two LinkedLists, which is only possible if they use the same underlying allocator.

One way to do this would be to require all implementations of the Allocator trait to implement Eq by making Eq a supertrait of Allocator. We already have wording to the effect that clones of an allocator can free each other's memory, so we can just extend this by saying that clones of an allocator must be equal to each other as per Eq.

This is expected to be a very cheap operation: for ZST allocators such as Global this is a no-op that always returns true. Foe stateful allocators it is a comparison of the pointers to their internal state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions