Closed vschwaberow closed 1 month ago
Hello. Many thanks for your reply to this pull request. That was very fast. Kudos.
The introduction of AllocationError addresses a specific use case where users of this hash table implementation might need more control over memory allocation, particularly in memory-constrained environments or when implementing higher-level data structures. In applications where memory usage needs to be tightly controlled (e.g., long-running servers, resource-intensive data processing pipelines), handling allocation failures programmatically can help prevent unexpected crashes and allow for more graceful degradation of service.
Last but not least, when testing the hash table implementation or using it in fuzz testing scenarios, the ability to handle and verify allocation failures can be valuable for ensuring the code's robustness under various conditions.
try_capacity seems to be more reasonable! Let's pick up your valuable input and I will add this to this PR, if you like.
Hi, can you give some context for this change? We would need to expose it in the public API to be useful. Something like
try_with_capacity
ortry_reserve
from hashbrown is reasonable.Also unsure about the power of two error here, capacities are rounded to a power of two internally so that should never cause any errors.