taproot_c_scape/sync_cell.rs
1//! `core::cell::SyncUnsafeCell` is still unstable (rust#95439); this is
2//! the same ten lines, locally. delete when the std type stabilizes.
3use core::cell::UnsafeCell;
4
5#[repr(transparent)]
6pub struct SyncUnsafeCell<T: ?Sized>(UnsafeCell<T>);
7
8unsafe impl<T: ?Sized> Sync for SyncUnsafeCell<T> {}
9
10impl<T> SyncUnsafeCell<T> {
11 pub const fn new(value: T) -> Self {
12 Self(UnsafeCell::new(value))
13 }
14}
15
16impl<T: ?Sized> SyncUnsafeCell<T> {
17 pub const fn get(&self) -> *mut T {
18 self.0.get()
19 }
20}