about summary refs log tree commit diff
path: root/library/std/src/thread/local.rs
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-12-20 19:21:53 +0100
committerMara Bos <m-ou.se@m-ou.se>2022-03-05 11:39:03 +0100
commit3b9e214c406fd1a899d4324ad20ffb0de6823abb (patch)
tree5825172551d8d80031d2b230ee38953a070c223a /library/std/src/thread/local.rs
parentc68c384b889943d0f1d08dbd8944e09a15f6929a (diff)
downloadrust-3b9e214c406fd1a899d4324ad20ffb0de6823abb.tar.gz
rust-3b9e214c406fd1a899d4324ad20ffb0de6823abb.zip
Small fixes in thread local code.
Diffstat (limited to 'library/std/src/thread/local.rs')
-rw-r--r--library/std/src/thread/local.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs
index 80632421573..a100444f049 100644
--- a/library/std/src/thread/local.rs
+++ b/library/std/src/thread/local.rs
@@ -630,7 +630,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
     where
         F: FnOnce(&T) -> R,
     {
-        self.with(|cell| f(&mut cell.borrow()))
+        self.with(|cell| f(&cell.borrow()))
     }
 
     /// Acquires a mutable reference to the contained value.
@@ -703,7 +703,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
                 // The cell was already initialized, so `value` wasn't used to
                 // initialize it. So we overwrite the current value with the
                 // new one instead.
-                cell.replace(init.into_inner());
+                *cell.borrow_mut() = value.into_inner();
             }
         });
     }