-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for RefCell::{replace, swap} #43570
Comments
Can I implement this? (I understand you'll want to give it the C-assigned label, to make sure nobody else works on it) |
Certainly! |
Implement `RefCell::replace` and `RefCell::swap` Tracking issue: #43570
|
The only docs needed for this is the API docs. I've also written PR #45819 to add a |
Is there any plan to make this stable ? I can't figure the syntax to move a value inside a RefCell to replace the old one. |
Stablize RefCell::{replace, swap} RefCell::replace_with is not stablized in this PR, since it wasn't part of the RFC. CC rust-lang#43570
Stabilized in #46517 |
Let’s stabilize it now, perhaps with the “corresponds to @rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@rfcbot concern footgun I'd personally be somewhat concerned about the |
I'm also under the impression that this isn't a massively used method in the sense that the ergonomic win here isn't necessary critical, but I could be wrong! |
I sent the PR for it because I wrote the function freely in my own code where I wanted to recurse through a path in a tree without passing a Vec of RefCell borrows but rather keep the borrow information in the stack. Putting a warning that the RefCell is borrowed for the duration of the closure into the documentation would help. |
@SimonSapin do you have thoughts on the concern I listed above? I'm not personally a huge fan of a warning in the sense that I don't think it absolves us of the footgun of the API, but if there's a strong use case for adding it then the warning is likely enough. I do not currently see, however, the strong use case for adding this |
This has been merged. Tracking issue can be closed. |
|
Ah. I thought that would be a different issue, because it's not in the title and not in the RFC. Sorry. |
@rfcbot resolve footgun I don't want to personally be on the hook for blocking this any more |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
Seems like this just needs a stabilization PR now? |
…swap, r=Centril Stabilize refcell_replace_swap feature Please be kind, this is my first time contributing. 😄 I noticed rust-lang#43570 only needs stabilizing (and I need it for a side project I'm working on), so I followed the [guide](https://rust-lang.github.io/rustc-guide/stabilization_guide.html#stabilization-pr) to move things forward. I'm happy to amend things if needed, let me know!
Tracking issue for rust-lang/rfcs#2057
The text was updated successfully, but these errors were encountered: