hashbrown icon indicating copy to clipboard operation
hashbrown copied to clipboard

immutable access to RawTable?

Open tower120 opened this issue 2 years ago • 6 comments

Why there is no immutable access to RawTable both in HashMap and HashSet?

For example, I want to emulate absent HashSet::raw_entry().from_hash... with HashSet::raw_table().get() but there is only mutable access to underlying RawTable in both HashSet and HashMap.

And is there a reason why there is no raw_entry API for HashSet?

tower120 avatar Feb 22 '23 12:02 tower120

This is an oversight. We should probably have both raw_table and raw_table_mut methods.

There is no raw_entry API for HashSet simply because nobody has implemented one yet. But then again there are concerns about the raw entry API and whether we should keep it at all.

Amanieu avatar Feb 22 '23 12:02 Amanieu

OK. I can implement raw_table + raw_table_mut and PR it - that's not problem.

Wouldn't it be a breaking change? Maybe something like raw_table_immut instead?

tower120 avatar Feb 22 '23 12:02 tower120

The raw API isn't very stable, it's fine to make breaking changes. We'll just make another major version bump.

Amanieu avatar Feb 22 '23 12:02 Amanieu

So can I do it now? Will you review/accept that PR?

tower120 avatar Feb 22 '23 12:02 tower120

Yes, but it may take a while until we actually publish a new release. I want to get all of the breaking changes in at once.

Amanieu avatar Feb 22 '23 12:02 Amanieu

OK - sure. I'm starting the implementation.

tower120 avatar Feb 22 '23 12:02 tower120