Skip to content
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 'take', 'replace', 'replace_with' from std::cell::RefCell #2

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

twilco
Copy link
Contributor

@twilco twilco commented Dec 11, 2020

This PR:

  • Adds take, replace, and replace_with from std::cell::RefCell
  • Adds a rust-toolchain file to codify the expectation that this crate targets stable Rust.

This PR also clarifies the language around mutable borrows. The message accountable_refcell currently panics with when trying to take a mutable borrow is not entirely accurate ("RefCell is already immutably borrowed"), as panics can also occur when trying to mutably borrow a RefCell that is already mutably borrowed.

Technically, at the time of this writing, the take method is not in stable Rust but will be in the next version (1.49) rust-lang/rust#71395. Is it OK to add it now, or would you prefer to wait on this?

This changeset also clarifies the language around mutable borrows.  The
message accountable_refcell paniced with when trying to take a mutable
borrow was not entirely accurate ("RefCell is already immutably borrowed"),
as panics can also occur when trying to mutably borrow a RefCell that is
already mutably borrowed.

Technically, at the time of this writing, the `take` method is not in
stable Rust, but will be in the next version (1.49) rust-lang/rust#71395

A rust-toolchain file has been added codifying the expectation that this
crate targets stable Rust.
@jdm jdm merged commit 48c09c6 into jdm:master Dec 11, 2020
@jdm
Copy link
Owner

jdm commented Dec 11, 2020

Looks great! Thanks for adding these!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants