Implement a `replace_full` method on `IndexSet`
Closed this issue · 3 comments
zakcutner commented
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 commented
Do you mean on IndexSet
? If so, that makes sense to me.
zakcutner commented
Do you mean on
IndexSet
?
Yes, I do 😅 Sorry, I've updated the issue!