#[repr(C)]pub struct Boxed<'a, T: ?Sized + 'a, A: Allocator = PoolAlloc> { /* private fields */ }
Implementations§
Source§impl Boxed<'static, (), PoolAlloc>
利用函数的泛型参数方便推导出Boxed<’a, T, A>的类型参数
impl Boxed<'static, (), PoolAlloc>
利用函数的泛型参数方便推导出Boxed<’a, T, A>的类型参数
pub fn zeroed<T>() -> Result<Boxed<'static, MaybeUninit<T>, PoolAlloc>>
pub fn uninit<T>() -> Result<Boxed<'static, MaybeUninit<T>, PoolAlloc>>
pub fn zeroed_slice<T>( len: usize, ) -> Result<Boxed<'static, [MaybeUninit<T>], PoolAlloc>>
pub fn uninit_slice<T>( len: usize, ) -> Result<Boxed<'static, [MaybeUninit<T>], PoolAlloc>>
pub fn new_then<T, F>(f: F) -> Result<Boxed<'static, T, PoolAlloc>>
pub fn new_slice_then<T, F>( len: usize, f: F, ) -> Result<Boxed<'static, [T], PoolAlloc>>
Source§impl<'a, A: Allocator> Boxed<'a, (), A>
impl<'a, A: Allocator> Boxed<'a, (), A>
pub fn zeroed_in<T>(alloc: &'a A) -> Result<Boxed<'a, MaybeUninit<T>, A>>
pub fn uninit_in<T>(alloc: &'a A) -> Result<Boxed<'a, MaybeUninit<T>, A>>
pub fn zeroed_slice_in<T>( alloc: &'a A, len: usize, ) -> Result<Boxed<'a, [MaybeUninit<T>], A>>
pub fn uninit_slice_in<T>( alloc: &'a A, len: usize, ) -> Result<Boxed<'a, [MaybeUninit<T>], A>>
pub fn new_then_in<T, F>(alloc: &'a A, f: F) -> Result<Boxed<'a, T, A>>
pub fn new_slice_then_in<T, F>( alloc: &'a A, len: usize, f: F, ) -> Result<Boxed<'a, [T], A>>
Source§impl<T> Boxed<'_, [T], NullAlloc>
impl<T> Boxed<'_, [T], NullAlloc>
Sourcepub unsafe fn from_raw_slice(data: *mut T, len: usize) -> Self
pub unsafe fn from_raw_slice(data: *mut T, len: usize) -> Self
§Safety
data and len should be valid slice
Source§impl<'a, T, A: Allocator> Boxed<'a, MaybeUninit<T>, A>
impl<'a, T, A: Allocator> Boxed<'a, MaybeUninit<T>, A>
Source§impl<'a, T, A: Allocator> Boxed<'a, [MaybeUninit<T>], A>
impl<'a, T, A: Allocator> Boxed<'a, [MaybeUninit<T>], A>
Source§impl<'a, T: ?Sized + 'a, A: Allocator> Boxed<'a, T, A>
impl<'a, T: ?Sized + 'a, A: Allocator> Boxed<'a, T, A>
Sourcepub unsafe fn from_with(ptr: NonNull<T>, layout: Layout, alloc: &'a A) -> Self
pub unsafe fn from_with(ptr: NonNull<T>, layout: Layout, alloc: &'a A) -> Self
§Safety
用户保证(ptr, layout, alloc)是Boxed::leak的返回值
Sourcepub unsafe fn from_boxed(data: Boxed<'a, T, NullAlloc>, alloc: &'a A) -> Self
pub unsafe fn from_boxed(data: Boxed<'a, T, NullAlloc>, alloc: &'a A) -> Self
§Safety
用户保证data是leak_boxed的返回值, 且是从alloc分配的内存
pub const fn as_ptr(&self) -> *mut T
Sourcepub unsafe fn as_other_mut<U>(&mut self) -> &mut U
pub unsafe fn as_other_mut<U>(&mut self) -> &mut U
§Safety
使用人员需要保证类型内存布局相同
Sourcepub unsafe fn as_slice_mut<U>(&mut self, len: usize) -> &mut [U]
pub unsafe fn as_slice_mut<U>(&mut self, len: usize) -> &mut [U]
§Safety
使用人员需要保证转换后类型/长度的正确性
Sourcepub unsafe fn cast_unchecked<U>(self) -> Boxed<'a, U, A>
pub unsafe fn cast_unchecked<U>(self) -> Boxed<'a, U, A>
§Safety
使用人员需要保证U/T的内存布局相同, 可用于从某个trait转为为具体实现类场景.
Sourcepub unsafe fn cast_slice<U>(self, len: usize) -> Result<Boxed<'a, [U], A>, Self>
pub unsafe fn cast_slice<U>(self, len: usize) -> Result<Boxed<'a, [U], A>, Self>
§Safety
使用人员需要保证U/T的内存布局相同
Sourcepub unsafe fn cast_slice_unchecked<U>(self, len: usize) -> Boxed<'a, [U], A>
pub unsafe fn cast_slice_unchecked<U>(self, len: usize) -> Boxed<'a, [U], A>
§Safety
使用人员需要保证U/T的内存布局相同
pub fn leak(self) -> (&'a mut T, Layout, &'a A)
Sourcepub fn leak_boxed(self) -> Boxed<'a, T, NullAlloc>
pub fn leak_boxed(self) -> Boxed<'a, T, NullAlloc>
资源所有权转移,但是其内存不会被释放
Trait Implementations§
Source§impl<T: ?Sized + Hasher, A: Allocator> Hasher for Boxed<'_, T, A>
impl<T: ?Sized + Hasher, A: Allocator> Hasher for Boxed<'_, T, A>
Source§fn write_u128(&mut self, data: u128)
fn write_u128(&mut self, data: u128)
Writes a single
u128
into this hasher.Source§fn write_usize(&mut self, data: usize)
fn write_usize(&mut self, data: usize)
Writes a single
usize
into this hasher.Source§fn write_isize(&mut self, data: isize)
fn write_isize(&mut self, data: isize)
Writes a single
isize
into this hasher.Source§fn write_i128(&mut self, data: i128)
fn write_i128(&mut self, data: i128)
Writes a single
i128
into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
🔬This is a nightly-only experimental API. (
hasher_prefixfree_extras
)Writes a length prefix into this hasher, as part of being prefix-free. Read more
Source§impl<T: ?Sized + Ord, A: Allocator> Ord for Boxed<'_, T, A>
impl<T: ?Sized + Ord, A: Allocator> Ord for Boxed<'_, T, A>
Source§impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Boxed<'_, T, A>
impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Boxed<'_, T, A>
impl<T: ?Sized + Eq, A: Allocator> Eq for Boxed<'_, T, A>
impl<T: ?Sized + Allocator + Pool, A: Allocator> Pool for Boxed<'_, T, A>
impl<T: ?Sized + Send, A: Allocator + Pool> Send for Boxed<'static, T, A>
impl<T: ?Sized + Sync, A: Allocator> Sync for Boxed<'static, T, A>
impl<T: ?Sized + Unpin, A: Allocator> Unpin for Boxed<'_, T, A>
Auto Trait Implementations§
impl<'a, T, A> Freeze for Boxed<'a, T, A>where
T: ?Sized,
impl<'a, T, A> RefUnwindSafe for Boxed<'a, T, A>
impl<'a, T, A> UnwindSafe for Boxed<'a, T, A>
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
Source§impl<A> GenericAlloc for A
impl<A> GenericAlloc for A
Source§unsafe fn init_slice<T>(
&self,
len: usize,
val: T,
) -> Result<NonNull<[T]>, Error>where
T: Clone,
unsafe fn init_slice<T>(
&self,
len: usize,
val: T,
) -> Result<NonNull<[T]>, Error>where
T: Clone,
Safety Read more
Source§unsafe fn alloc_slice_then<T, F>(
&self,
len: usize,
f: F,
) -> Result<NonNull<[T]>, Error>
unsafe fn alloc_slice_then<T, F>( &self, len: usize, f: F, ) -> Result<NonNull<[T]>, Error>
Safety Read more
Source§unsafe fn zeroed_slice<T>(
&self,
len: usize,
) -> Result<NonNull<[MaybeUninit<T>]>, Error>
unsafe fn zeroed_slice<T>( &self, len: usize, ) -> Result<NonNull<[MaybeUninit<T>]>, Error>
Safety Read more
Source§unsafe fn uninit_slice<T>(
&self,
len: usize,
) -> Result<NonNull<[MaybeUninit<T>]>, Error>
unsafe fn uninit_slice<T>( &self, len: usize, ) -> Result<NonNull<[MaybeUninit<T>]>, Error>
Safety Read more