pub struct UninitBox { /* private fields */ }
Expand description
An uninitialized piece of memory
Implementations§
Source§impl UninitBox
impl UninitBox
Sourcepub fn from_layout(layout: Layout) -> Self
pub fn from_layout(layout: Layout) -> Self
Create a new allocation that can fit the given layout
Sourcepub fn init<T>(self, value: T) -> Box<T>
pub fn init<T>(self, value: T) -> Box<T>
Initialize the box with the given value,
§Panic
if std::alloc::Layout::new::<T>() != self.layout()
then
this function will panic
Sourcepub fn init_with<T, F: FnOnce() -> T>(self, value: F) -> Box<T>
pub fn init_with<T, F: FnOnce() -> T>(self, value: F) -> Box<T>
Initialize the box with the given value,
§Panic
if std::alloc::Layout::new::<T>() != self.layout()
then
this function will panic
Sourcepub fn as_ptr(&self) -> *const ()
pub fn as_ptr(&self) -> *const ()
Get the pointer from the UninitBox
This pointer is not valid to write to
Sourcepub fn as_mut_ptr(&mut self) -> *mut ()
pub fn as_mut_ptr(&mut self) -> *mut ()
Get the pointer from the UninitBox
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UninitBox
impl RefUnwindSafe for UninitBox
impl !Send for UninitBox
impl !Sync for UninitBox
impl Unpin for UninitBox
impl UnwindSafe for UninitBox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more