• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[derive(Debug)]
2 pub(crate) struct UnsafeCell<T>(std::cell::UnsafeCell<T>);
3 
4 impl<T> UnsafeCell<T> {
new(data: T) -> UnsafeCell<T>5     pub(crate) const fn new(data: T) -> UnsafeCell<T> {
6         UnsafeCell(std::cell::UnsafeCell::new(data))
7     }
8 
with<R>(&self, f: impl FnOnce(*const T) -> R) -> R9     pub(crate) fn with<R>(&self, f: impl FnOnce(*const T) -> R) -> R {
10         f(self.0.get())
11     }
12 
with_mut<R>(&self, f: impl FnOnce(*mut T) -> R) -> R13     pub(crate) fn with_mut<R>(&self, f: impl FnOnce(*mut T) -> R) -> R {
14         f(self.0.get())
15     }
16 }
17