-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add drop_leak and drop_leak_mut #83786
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
How do I run just the two doctests locally? It seems to take forever to build and test any changes |
I guess #69099 should be updated to include this PR |
i think it's easier to copy the entire RefCell into its own crate outside of libstd during development. |
/// assert!(c.try_borrow_mut().is_err()); | ||
/// unsafe { c.drop_leak() }; | ||
/// assert!(c.try_borrow_mut().is_ok()); | ||
/// ``` |
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.
We should add a panic section to describe when this panics.
/// assert!(c.try_borrow().is_err()); | ||
/// unsafe { c.drop_leak_mut() }; | ||
/// assert!(c.try_borrow().is_ok()); | ||
/// ``` |
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.
Ditto.
Ping from triage |
@davidspies Ping from triage, any updates on this? |
Triage: I'm closing this due to inactivity. Feel free to reopen or create a new PR when you're ready to work on this again, thanks! |
I'm trying to implement a
StaticRef
type which can be built fromRc<RefCell<T>>
without needing a lifetime (when dropped, it decrements the refcount and the borrow count). But I find thatundo_leak
doesn't quite do what I want it to do in the presence of multipleStaticRef
s, so I'd like to adddrop_leak
.Here's the implementation of
StaticRef
: