Struct phper_alloc::EBox
source · pub struct EBox<T> { /* private fields */ }Expand description
The Box which use php emalloc and efree to manage memory.
TODO Now feature allocator_api is still unstable, implement myself, use
Box<T, Alloc> later.
Implementations§
source§impl<T> EBox<T>
impl<T> EBox<T>
sourcepub fn new(x: T) -> Self
pub fn new(x: T) -> Self
Allocates heap memory using emalloc then places x into it.
Panic
Panic if size_of::<T>() equals zero.
sourcepub unsafe fn from_raw(raw: *mut T) -> Self
pub unsafe fn from_raw(raw: *mut T) -> Self
Constructs from a raw pointer.
Safety
Make sure the pointer is from into_raw, or created from emalloc.
sourcepub fn into_raw(b: EBox<T>) -> *mut T
pub fn into_raw(b: EBox<T>) -> *mut T
Consumes and returning a wrapped raw pointer.
Will leak memory.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the EBox, returning the wrapped value.
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for EBox<T>where T: RefUnwindSafe,
impl<T> !Send for EBox<T>
impl<T> !Sync for EBox<T>
impl<T> Unpin for EBox<T>
impl<T> UnwindSafe for EBox<T>where T: RefUnwindSafe,
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