1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use core::cell::UnsafeCell;
use crate::utils::{Init, Zeroable};
#[derive(Debug)]
#[repr(transparent)]
pub struct RawCell<T: ?Sized>(UnsafeCell<T>);
unsafe impl<T: Sync + ?Sized> Sync for RawCell<T> {}
impl<T> RawCell<T> {
pub const fn new(x: T) -> Self {
Self(UnsafeCell::new(x))
}
pub fn into_inner(self) -> T {
self.0.into_inner()
}
}
impl<T: ?Sized> RawCell<T> {
pub const fn get(&self) -> *mut T {
self.0.get()
}
}
impl<T: Init> Init for RawCell<T> {
const INIT: Self = RawCell::new(T::INIT);
}
unsafe impl<T: Zeroable> Zeroable for RawCell<T> {}