-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allocator equality #109
Comments
I gave this a try and it's tricker than it seems. The core issue is that requiring |
I imagine that And allocator safety guidelines will mention that if two allocators are comparable (there's Additionally there can be trait for stateless allocator types to signal that all instances of that type are equal. Naturally |
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
LinkedList
s, 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 implementEq
by makingEq
a supertrait ofAllocator
. 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 perEq
.This is expected to be a very cheap operation: for ZST allocators such as
Global
this is a no-op that always returnstrue
. Foe stateful allocators it is a comparison of the pointers to their internal state.The text was updated successfully, but these errors were encountered: