Nothing to see here, move along
1use core::cell::UnsafeCell;
2
3#[repr(transparent)]
4pub struct SyncUnsafe<T>(UnsafeCell<T>);
5
6unsafe impl<T: Send> Sync for SyncUnsafe<T> {}
7
8impl<T> SyncUnsafe<T> {
9 pub const fn new(val: T) -> Self {
10 Self(UnsafeCell::new(val))
11 }
12
13 pub const fn get(&self) -> *mut T {
14 self.0.get()
15 }
16
17 #[allow(clippy::mut_from_ref, clippy::missing_safety_doc)]
18 pub unsafe fn as_mut_unchecked(&self) -> &mut T {
19 unsafe { &mut *self.0.get() }
20 }
21
22 #[allow(clippy::missing_safety_doc)]
23 pub unsafe fn as_ref_unchecked(&self) -> &T {
24 unsafe { &*self.0.get() }
25 }
26}