indexmap icon indicating copy to clipboard operation
indexmap copied to clipboard

Feature Request: IndexSet entry APIs

Open zao111222333 opened this issue 9 months ago • 5 comments

I wonder whether IndexSet::entry is in the roadmap, if yes, I can try to submit PR. Like the one in hashbrown::HashSet, for IndexSet it will be

impl<T, S> IndexSet<T, S>
where
    T: Hash + Eq,
    S: BuildHasher,
{
    pub fn entry(&mut self, value: T) -> Entry<'_, T, S> { ... }
}
pub enum Entry<'a,T,S> { ... }

zao111222333 avatar Apr 08 '25 13:04 zao111222333

Yes, but I'll want to match the eventual API of the standard library HashSet, rust-lang/rust#60896. I don't mind having a draft PR waiting for that, if you're so inclined, but it could be a while before that will be merged.

cuviper avatar Apr 08 '25 17:04 cuviper

I presume you're talking about the trait that the Hash macro derives?

If so I would be interested in contributing a PR for this. Seems like an easy fix.

colbyn avatar Jul 21 '25 06:07 colbyn

Oh wait never mind disregard my last comment (coding super late)

colbyn avatar Jul 21 '25 06:07 colbyn

Although I can add Entry as well, I've implemented it before and its super easy to implement and its very useful

colbyn avatar Jul 21 '25 06:07 colbyn

As I mentioned before, the standard library is the blocker to make sure we match a stable API. I agree the implementation is not hard, and if you want you can open that, but it will be blocked for the foreseeable future.

cuviper avatar Jul 21 '25 16:07 cuviper