WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@AlexanderPortland
Copy link

In some niche use cases, it seems useful for &Bump to implement both core::alloc::Allocator and allocator-api2::alloc::Allocator at once. This has come up for me specifically when using data structures from different crates which were generic over those differing allocator traits.

However, simply enabling both the "allocator_api" and "allocator-api2" features doesn't work because there's only a single impl block that's conditionally compiled if either feature is enabled. This causes the "allocator_api" implementation to overwrite the "allocator-api2" one.

If this is intended behavior, would it be alright if I add a note to the README to that effect to help others who might be confused like I was initially? And if not, this PR just introduces two separate impl blocks so that &Bump can satisfy both traits simultaneously.

@fitzgen
Copy link
Owner

fitzgen commented Jul 24, 2025

The allocator_api2::alloc::Allocator trait should become just a re-export of the core::alloc::Allocator trait when using nightly and enabling the unstable allocator-api Rust feature. If things aren't working as expected, happy to help clarify and brainstorm fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants