Skip to content
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-api2 default-feature? #484

Open
kristof-mattei opened this issue Nov 10, 2023 · 2 comments
Open

allocator-api2 default-feature? #484

kristof-mattei opened this issue Nov 10, 2023 · 2 comments

Comments

@kristof-mattei
Copy link

Hi,

I'm updating some codebase and noticed the changes wrt allocator-api2.

#417

I want to lead with the fact that I am not an advanced Rust developer, so my question may be (probably is) stupid.

From my (limited) experience, I'm not sure I understand why this feature is on by default.

I would expect a custom allocator to be opt-in, specially since it forms the foundation of all the types. It feels weird hashbrown by default uses a different allocator (albeit a c/p of the official one) than the other pieces of code that I have.

I am concerned about minor updates that could change how the allocators work as they might go out of sync.

So to alleviate that, I turned off all default features and only enabled ahash.

Next to the question above, as to why it is default, I am wondering if the turning off default features and just adding ahash is the right way to address the concern?

Thanks.

@Amanieu
Copy link
Member

Amanieu commented Nov 15, 2023

I don't understand the concern. If no allocator is specified then it will always default to the global allocator (specified with #[global_allocator]. The Global allocator in allocator-api2 forwards to this.

The only reason this is an optional feature is that it needs to be disabled when hashbrown is built as part of the standard library.

@kristof-mattei
Copy link
Author

https://github.com/rust-lang/hashbrown/pull/417/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R41

My concern is that allocator-api2 is pulled in by default if we don't disable it.

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

No branches or pull requests

2 participants