tokio/loom/std/
unsafe_cell.rs

1#[derive(Debug)]
2pub(crate) struct UnsafeCell<T>(std::cell::UnsafeCell<T>);
3
4impl<T> UnsafeCell<T> {
5    pub(crate) const fn new(data: T) -> UnsafeCell<T> {
6        UnsafeCell(std::cell::UnsafeCell::new(data))
7    }
8
9    #[inline(always)]
10    pub(crate) fn with<R>(&self, f: impl FnOnce(*const T) -> R) -> R {
11        f(self.0.get())
12    }
13
14    #[inline(always)]
15    pub(crate) fn with_mut<R>(&self, f: impl FnOnce(*mut T) -> R) -> R {
16        f(self.0.get())
17    }
18}