-
Notifications
You must be signed in to change notification settings - Fork 14k
Rename DropGuard::into_inner to DropGuard::dismiss
#148589
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
base: master
Are you sure you want to change the base?
Conversation
Also changes it from a static method to an instance method.
|
rustbot has assigned @Mark-Simulacrum. Use |
This comment has been minimized.
This comment has been minimized.
|
Some alternative options (since I did not see any yet):
|
|
In the tracking issue, ACP, impl PR, and libs-api meeting the following options were brought up as well:
That leaves us with: |
|
I assume libs-api nominated is appropriate? |
|
Yes, that's great - thank you! |
|
@yoshuawuyts If a guard guards a thing and you dismiss them, what happens with the thing? I guess it depends on how big/heavy the thing is. I think I like
|
Tracking issue: #144426
One of the open questions blocking the stabilization of
DropGuardis what to name the associated method that prevents the destructor from running, and returns the captured value. This method is currently calledinto_inner, but most people (including myself) feel like this would benefit from a method that calls more attention to itself.This PR proposes naming this method
dismiss, after the Linux kernel'sScopeGuard::dismiss. Which crucially does not evoke images of violence or weaponry the way alternatives such as "disarm" or "defuse" do. And personally I enjoy the visual metaphor of "dismissing a guard" (e.g. a person keeping watch over something) - a job well done, they're free to go.This PR also changes the signature from an static method to an instance method. This also matches the Linux kernel's API, and seems alright since
dismissis not nearly as ubiquitous asinto_inner. This makes it more convenient to use, with a much lower risk of conflicting. Though in the rare case there might be ambiguity, the explicit notation is available as a fallback.