Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement `RefCell::replace` and `RefCell::swap` #43574
Conversation
rust-highfive
assigned
BurntSushi
Jul 31, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @BurntSushi (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. |
frewsxcv
added
the
T-libs
label
Aug 2, 2017
frewsxcv
reviewed
Aug 2, 2017
| /// | ||
| /// This function corresponds to [`std::mem::replace`](../mem/fn.replace.html). | ||
| /// | ||
| /// # Example |
This comment has been minimized.
This comment has been minimized.
| /// | ||
| /// This function corresponds to [`std::mem::swap`](../mem/fn.swap.html). | ||
| /// | ||
| /// # Example |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Those problems are fixed now. |
aidanhs
added
the
S-waiting-on-review
label
Aug 3, 2017
This comment has been minimized.
This comment has been minimized.
|
r? @sfackler |
arielb1
assigned
sfackler
and unassigned
BurntSushi
Aug 8, 2017
sfackler
reviewed
Aug 8, 2017
| /// | ||
| /// # Panics | ||
| /// | ||
| /// This function will panic if the `RefCell` has any outstanding borrows, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
notriddle
Aug 8, 2017
Author
Contributor
There is only one RefCell involved in a RefCell::replace. This is different from RefCell::swap, which does actually involve two of them.
This comment has been minimized.
This comment has been minimized.
sfackler
reviewed
Aug 8, 2017
| @@ -543,6 +543,59 @@ impl<T> RefCell<T> { | |||
| debug_assert!(self.borrow.get() == UNUSED); | |||
| unsafe { self.value.into_inner() } | |||
| } | |||
|
|
|||
| /// Replaces the wrapped value with a new one, returning the old value, | |||
This comment has been minimized.
This comment has been minimized.
sfackler
Aug 8, 2017
Member
I wonder if the docs should mention that these are simply convenience functions for their one-liner implementations? I wouldn't want people thinking that they're more "magical" than they really are. Thoughts @steveklabnik? Not sure if we do something similar elsewhere.
This comment has been minimized.
This comment has been minimized.
|
ping @sfackler, looks like this is ready for your rereview! |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Aug 14, 2017
This comment has been minimized.
This comment has been minimized.
|
|
notriddle commentedJul 31, 2017
Tracking issue: #43570