-
Couldn't load subscription status.
- Fork 10
Description
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.