about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-05-03 18:34:34 +0200
committerGitHub <noreply@github.com>2020-05-03 18:34:34 +0200
commit6f5de87d3f9f192e00defe9a15e8396c13c2ec0c (patch)
tree2abe45831799f97a5f86e08c910cc7d5a515778f /src/libstd
parente5f35df2c6944b843b08369c4b2ff3bdb0beb2d2 (diff)
parent4a79424b748338bd9635f0115c025942af2d5c3d (diff)
downloadrust-6f5de87d3f9f192e00defe9a15e8396c13c2ec0c.tar.gz
rust-6f5de87d3f9f192e00defe9a15e8396c13c2ec0c.zip
Rollup merge of #71398 - ThinkChaos:feat_refcell_take, r=LukasKalbertodt
Add `RefCell::take`

Add `RefCell::take` to match `Cell` and `Option`.
I also changed a couple of calls to `.replace` to `.take`.

Tracking issue is #71395.

This is my first contribution, please tell me if there's anything I could improve, thanks!
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sync/once.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs
index 1e6b6c430be..a3ee14e85d2 100644
--- a/src/libstd/sync/once.rs
+++ b/src/libstd/sync/once.rs
@@ -497,7 +497,7 @@ impl Drop for WaiterQueue<'_> {
             let mut queue = (state_and_queue & !STATE_MASK) as *const Waiter;
             while !queue.is_null() {
                 let next = (*queue).next;
-                let thread = (*queue).thread.replace(None).unwrap();
+                let thread = (*queue).thread.take().unwrap();
                 (*queue).signaled.store(true, Ordering::Release);
                 // ^- FIXME (maybe): This is another case of issue #55005
                 // `store()` has a potentially dangling ref to `signaled`.