Struct SyncNoinit
pub struct SyncNoinit<T>(pub UnsafeCell<MaybeUninit<T>>);Expand description
A Sync wrapper around UnsafeCell<MaybeUninit<T>> for use with
#[link_section = ".uninit"] statics.
Rust 2024 made &mut static_mut a hard error (static_mut_refs lint).
UnsafeCell is the correct escape hatch: it opts into interior
mutability, so a raw pointer obtained via UnsafeCell::get() is not a
reference to a mutable static. The unsafe impl Sync is sound on a
single-core target where no thread can race on the cell.
Tuple Fields§
§0: UnsafeCell<MaybeUninit<T>>Implementations§
§impl<T> SyncNoinit<T>
impl<T> SyncNoinit<T>
pub const fn uninit() -> SyncNoinit<T>
pub unsafe fn as_bytes_mut(&self) -> &'static mut [u8]
pub unsafe fn as_bytes_mut(&self) -> &'static mut [u8]
Return a &'static mut [u8] slice over the inner value.
§Safety
The caller must ensure no other live reference to this cell exists.