add Mut<>::uninit

This commit is contained in:
Intege-rs
2024-11-16 20:38:23 -05:00
parent f524b3c3a5
commit 5bdf077475

View File

@@ -43,6 +43,10 @@ impl<T: Pod> Mut<T> {
pub fn set(&self, value: T) { unsafe { core::ptr::write(self.as_ptr(), value) } } pub fn set(&self, value: T) { unsafe { core::ptr::write(self.as_ptr(), value) } }
pub fn get(&self) -> T { unsafe { core::ptr::read(self.as_ptr()) } } pub fn get(&self) -> T { unsafe { core::ptr::read(self.as_ptr()) } }
} }
impl<T> Mut<MaybeUninit<T>> {
pub const fn zeroed() -> Self { Self(core::cell::UnsafeCell::new(MaybeUninit::zeroed())) }
pub const fn uninit() -> Self { Self(core::cell::UnsafeCell::new(MaybeUninit::uninit())) }
}
impl<T> Deref for Mut<T> { impl<T> Deref for Mut<T> {
type Target = core::cell::UnsafeCell<T>; type Target = core::cell::UnsafeCell<T>;