#[repr(C)]pub struct Box<T, Alloc: IAlloc = DefaultAllocator> { /* private fields */ }Expand description
An ABI-stable Box, provided Alloc is ABI-stable.
Implementations§
Source§impl<T, Alloc: IAlloc> Box<T, Alloc>
impl<T, Alloc: IAlloc> Box<T, Alloc>
Sourcepub const fn has_optimal_layout() -> bool
pub const fn has_optimal_layout() -> bool
Returns true if the layout for Box is smaller or equal to that Rust would have generated for it.
Source§impl<T> Box<T>
impl<T> Box<T>
Sourcepub unsafe fn make<F: for<'a> FnOnce(&'a mut MaybeUninit<T>) -> Result<&'a mut T, ()>>(
constructor: F,
) -> Result<Self, Box<MaybeUninit<T>>>
pub unsafe fn make<F: for<'a> FnOnce(&'a mut MaybeUninit<T>) -> Result<&'a mut T, ()>>( constructor: F, ) -> Result<Self, Box<MaybeUninit<T>>>
Attempts to allocate Self, initializing it with constructor.
Note that the allocation may or may not be zeroed.
If the allocation fails, the constructor will not be run.
§Safety
constructor MUST return Err(()) if it failed to initialize the passed argument.
§Errors
Returns the uninitialized allocation if the constructor declares a failure.
§Panics
If the allocator fails to provide an appropriate allocation.
Source§impl<T, Alloc: IAlloc> Box<T, Alloc>
impl<T, Alloc: IAlloc> Box<T, Alloc>
Sourcepub unsafe fn try_make_in<F: for<'a> FnOnce(&'a mut MaybeUninit<T>) -> Result<&'a mut T, ()>>(
constructor: F,
alloc: Alloc,
) -> Result<Self, Result<Box<MaybeUninit<T>, Alloc>, (F, Alloc)>>
pub unsafe fn try_make_in<F: for<'a> FnOnce(&'a mut MaybeUninit<T>) -> Result<&'a mut T, ()>>( constructor: F, alloc: Alloc, ) -> Result<Self, Result<Box<MaybeUninit<T>, Alloc>, (F, Alloc)>>
Attempts to allocate Self, initializing it with constructor.
Note that the allocation may or may not be zeroed.
If the constructor panics, the allocated memory will be leaked.
§Errors
- Returns the
constructorand the allocator in case of allocation failure. - Returns the uninitialized allocated memory if
constructorfails.
§Safety
constructor MUST return Err(()) if it failed to initialize the passed argument.
§Notes
Note that the allocation may or may not be zeroed.
Sourcepub fn try_new_in(value: T, alloc: Alloc) -> Result<Self, (T, Alloc)>
pub fn try_new_in(value: T, alloc: Alloc) -> Result<Self, (T, Alloc)>
Sourcepub unsafe fn make_in<F: for<'a> FnOnce(&'a mut MaybeUninit<T>) -> Result<&'a mut T, ()>>(
constructor: F,
alloc: Alloc,
) -> Result<Self, Box<MaybeUninit<T>, Alloc>>
pub unsafe fn make_in<F: for<'a> FnOnce(&'a mut MaybeUninit<T>) -> Result<&'a mut T, ()>>( constructor: F, alloc: Alloc, ) -> Result<Self, Box<MaybeUninit<T>, Alloc>>
Attempts to allocate Self, initializing it with constructor.
Note that the allocation may or may not be zeroed.
§Errors
Returns the uninitialized allocated memory if constructor fails.
§Safety
constructor MUST return Err(()) if it failed to initialize the passed argument.
§Panics
If the allocator fails to provide an appropriate allocation.
Sourcepub fn into_inner(this: Self) -> T
pub fn into_inner(this: Self) -> T
Extracts the value from the allocation, freeing said allocation.
Trait Implementations§
Source§impl<T, Alloc: IAlloc> IPtrMut for Box<T, Alloc>
impl<T, Alloc: IAlloc> IPtrMut for Box<T, Alloc>
Source§unsafe fn as_mut(&mut self) -> AnonymRefMut<'_>
unsafe fn as_mut(&mut self) -> AnonymRefMut<'_>
Source§impl<T, Alloc: IAlloc> IPtrOwned for Box<T, Alloc>
impl<T, Alloc: IAlloc> IPtrOwned for Box<T, Alloc>
Source§fn drop(
this: &mut ManuallyDrop<Self>,
drop: unsafe extern "C" fn(AnonymRefMut<'_>),
)
fn drop( this: &mut ManuallyDrop<Self>, drop: unsafe extern "C" fn(AnonymRefMut<'_>), )
Drop::drop when the dynptr is dropped.Source§impl<T, Alloc: IAlloc> IStable for Box<T, Alloc>
impl<T, Alloc: IAlloc> IStable for Box<T, Alloc>
Source§const REPORT: &'static TypeReport
const REPORT: &'static TypeReport
Source§const ID: u64
const ID: u64
crate::report::gen_id, but can be manually set.Source§type ForbiddenValues = <Struct<AllocPtr<T, Alloc>> as IStable>::ForbiddenValues
type ForbiddenValues = <Struct<AllocPtr<T, Alloc>> as IStable>::ForbiddenValues
Source§type UnusedBits = <Struct<AllocPtr<T, Alloc>> as IStable>::UnusedBits
type UnusedBits = <Struct<AllocPtr<T, Alloc>> as IStable>::UnusedBits
Source§type Size = <Struct<AllocPtr<T, Alloc>> as IStable>::Size
type Size = <Struct<AllocPtr<T, Alloc>> as IStable>::Size
Source§type Align = <Struct<AllocPtr<T, Alloc>> as IStable>::Align
type Align = <Struct<AllocPtr<T, Alloc>> as IStable>::Align
Source§type HasExactlyOneNiche = <Struct<AllocPtr<T, Alloc>> as IStable>::HasExactlyOneNiche
type HasExactlyOneNiche = <Struct<AllocPtr<T, Alloc>> as IStable>::HasExactlyOneNiche
core::option::Options are stable: Read more