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

Implement a replace_full method on IndexSet #221

Closed
zakcutner opened this issue Mar 26, 2022 · 3 comments · Fixed by #222
Closed

Implement a replace_full method on IndexSet #221

zakcutner opened this issue Mar 26, 2022 · 3 comments · Fixed by #222

Comments

@zakcutner
Copy link
Contributor

zakcutner commented Mar 26, 2022

Hello! I was wondering whether it would be possible to implement a replace_full method on IndexSet? Similarly to how there are the insert and insert_full methods, I think it might also be useful to also have a replace_full method.

pub fn replace_full(&mut self, value: T) -> (usize, Option<T>)

I believe the semantics would be:

  • If the item already exists, replace it with value and return its index (which will remain unchanged) as well as its old value.
  • Otherwise, insert the item into the set and return its index as well as None.
@cuviper
Copy link
Member

cuviper commented Mar 26, 2022

Do you mean on IndexSet? If so, that makes sense to me.

@zakcutner zakcutner changed the title Implement a replace_full method on IndexMap Implement a replace_full method on IndexSet Mar 26, 2022
@zakcutner
Copy link
Contributor Author

Do you mean on IndexSet?

Yes, I do 😅 Sorry, I've updated the issue!

@zakcutner
Copy link
Contributor Author

I went ahead and created #222 with a possible implementation, I hope that's okay 🙂

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

Successfully merging a pull request may close this issue.

2 participants