pub struct Box<T: 'static + ?Sized> { /* private fields */ }
Expand description
Owned pointer to a T
.
Intended for similar use cases as the standard library Box
, but this one
does not free the memory on drop (though it does drop the T
). Used
sparingly in cases where we really need to own a dynamically allocated T
instead of borrowing it, and using a static borrow would be too verbose.
Implementations§
Source§impl<T: ?Sized> Box<T>
impl<T: ?Sized> Box<T>
Sourcepub fn from_mut(value: &'static mut T) -> Box<T>
pub fn from_mut(value: &'static mut T) -> Box<T>
Creates a Box
from a leaked borrow of the boxed value.
Sourcepub unsafe fn from_ptr(ptr: *mut T) -> Box<T>
pub unsafe fn from_ptr(ptr: *mut T) -> Box<T>
Creates a Box
from a raw pointer to the boxed value.
§Safety
The caller must ensure that the memory behind the pointer is never read,
written, or freed while this Box
exists, and that the T pointed to by
this pointer is never accessed after this call, unless it’s after
deconstructing this box with Box::into_ptr
.
Trait Implementations§
impl<T: ?Sized + Sync> Sync for Box<T>
Auto Trait Implementations§
impl<T> Freeze for Box<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Box<T>where
T: RefUnwindSafe + ?Sized,
impl<T> !Send for Box<T>
impl<T> Unpin for Box<T>where
T: ?Sized,
impl<T> UnwindSafe for Box<T>where
T: RefUnwindSafe + ?Sized,
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