We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c68c384 commit 3b9e214Copy full SHA for 3b9e214
library/std/src/thread/local.rs
@@ -630,7 +630,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
630
where
631
F: FnOnce(&T) -> R,
632
{
633
- self.with(|cell| f(&mut cell.borrow()))
+ self.with(|cell| f(&cell.borrow()))
634
}
635
636
/// Acquires a mutable reference to the contained value.
@@ -703,7 +703,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
703
// The cell was already initialized, so `value` wasn't used to
704
// initialize it. So we overwrite the current value with the
705
// new one instead.
706
- cell.replace(init.into_inner());
+ *cell.borrow_mut() = value.into_inner();
707
708
});
709
0 commit comments