-
Notifications
You must be signed in to change notification settings - Fork 161
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
Remove deprecation warnings on the removal methods again #107
Conversation
I'd like to do this, I guess it's a change of course but it's what feels best for me. My impression is taken from how rustc is using IndexMap as a HashMap drop in, so then I also wonder what the preference would be from them @Centril, if you know? 🙂 Would it be best with the friendly "Deprecation" warnings on plain ".remove()" or not? |
uhm... I've mostly approached |
I think rustc doesn't care much -- if we want to be specific about this we can always introduce our own lint around it or so. It's true right that swap_remove is entirely deterministic for a given insertion/deletion order? i.e., these functions default to a reasonable thing already from the perspective that "IndexMap is deterministic in all ways if used deterministically"? |
Both styles of removal are deterministic -- I feel like it's a footgun that |
Okay, yeah that's what I expected. I do think it is a plausible foot gun, yes -- I don't think de-deprecating will help rustc much here fwiw, so if that's the sole reason, don't do it. |
Hmm, speaking from the POV of "average index map user" (and not about rustc specifically), I would be fine with a clear warning in the docs on |
In case this isn't clear, the deprecation doesn't discourage |
src/map.rs
Outdated
@@ -1001,7 +1001,7 @@ impl<K, V, S> IndexMap<K, V, S> | |||
/// NOTE: Same as .swap_remove | |||
/// | |||
/// Computes in **O(1)** time (average). | |||
#[deprecated(note = "use `swap_remove`")] | |||
// #[deprecated(note = "use `swap_remove`")] |
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.
If we do keep this after all, it should also recommend "or shift_remove
".
8b06062
to
9e364c6
Compare
Thanks everyone for the feedback! The deprecation warnings get in they way for being a drop-in replacement for HashMap, which is still a goal. Deprecation warnings are not signaling the right thing - we want to say 'caution', but not that these methods are going away. I have removed the deprecations and improved the method docs to make it clear, the way it should have been from the start. |
Note, these methods are never scheduled to be removed. The warning was intended to guide the user towards being more explicit about which removal type they wanted. However, seeing how indexmap can be used as a drop in solution for HashMap, I again am dubious that these warnings should be there. Documentation for the methods has been improved.
9e364c6
to
268665b
Compare
Note, these methods are never scheduled to be removed. The warning was
intended to guide the user towards being more explicit about which
removal type they wanted (
swap_remove
orshift_remove
).However, seeing how indexmap can be used as a drop in solution for
HashMap, I again am dubious that these warnings should be there.
Documentation for the methods has been improved.