hashbrown
hashbrown copied to clipboard
allocator-api2 default-feature?
Hi,
I'm updating some codebase and noticed the changes wrt allocator-api2.
https://github.com/rust-lang/hashbrown/pull/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.
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.
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.