-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adds a default-implemented SecondaryMap::remove
#59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm. I see what you are aiming at here, but thoughts:
- The
must_use
-ness really belongs to the type of values, not the map: it may not make sense for all values, and should we really complicate the interface to the map in this way to support it? - IIUC, no warning is generated for
remove
, right? Soremove
shows how simple it is to bypass the warning. Folk could just do that themselves.... - Maybe we should use Rust's HashMap as a guide what to do here. It has only one method,
remove
, returning anOption<V>
. So we usedefault()
rather than option, but that suggests to me that we should renametake
toremove
and leave it at that....??
graph.remove_node(node);
hierarchy.remove(node);
secondary_map.???(node); |
Hmmmm, your second set of examples is quite convincing, I agree. So maybe |
I realize that's a bit harder to implement as
I could go either way there!! |
Yes, that's the main problem with that. if node_val != default {
secondary_map.set(node, node_val);
} (Note: this is automatically done by some impls) Returning a flag for whether the element was present when deleting it goes kind of against it. For the same reason we do not have a |
Another problem as you say is that we don't always have Note: I added a drive-by change to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah OK. I'm a bit meh but don't see anything better as it doesn't seem possible to be consistent with other classes' remove
methods :(
No description provided.