Skip to content

Commit 3b9e214

Browse files
committed
Small fixes in thread local code.
1 parent c68c384 commit 3b9e214

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/thread/local.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
630630
where
631631
F: FnOnce(&T) -> R,
632632
{
633-
self.with(|cell| f(&mut cell.borrow()))
633+
self.with(|cell| f(&cell.borrow()))
634634
}
635635

636636
/// Acquires a mutable reference to the contained value.
@@ -703,7 +703,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
703703
// The cell was already initialized, so `value` wasn't used to
704704
// initialize it. So we overwrite the current value with the
705705
// new one instead.
706-
cell.replace(init.into_inner());
706+
*cell.borrow_mut() = value.into_inner();
707707
}
708708
});
709709
}

0 commit comments

Comments
 (0)