pub struct WithoutDealloc<A>(pub A);
Expand description
Wraps a bump allocator and does nothing on deallocate
.
This type only implements Allocator
for wrapped types that implement BumpAllocator
, so you don’t accidentally leak memory.
Tuple Fields§
§0: A
Trait Implementations§
Source§impl<A: BumpAllocatorExt> Allocator for WithoutDealloc<A>
Available on crate feature nightly-allocator-api
only.
impl<A: BumpAllocatorExt> Allocator for WithoutDealloc<A>
Available on crate feature
nightly-allocator-api
only.Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Attempts to allocate a block of memory. Read more
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
🔬This is a nightly-only experimental API. (
allocator_api
)Deallocates the memory referenced by
ptr
. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Attempts to extend the memory block. Read more
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Behaves like
grow
, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Attempts to shrink the memory block. Read more
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Behaves like
allocate
, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A: BumpAllocatorExt> Allocator for WithoutDealloc<A>
Available on crate feature allocator-api2-03
only.
impl<A: BumpAllocatorExt> Allocator for WithoutDealloc<A>
Available on crate feature
allocator-api2-03
only.Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Attempts to allocate a block of memory. Read more
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
Deallocates the memory referenced by
ptr
. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Attempts to extend the memory block. Read more
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Behaves like
grow
, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Attempts to shrink the memory block. Read more
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Behaves like
allocate
, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A: BumpAllocator> Allocator for WithoutDealloc<A>
impl<A: BumpAllocator> Allocator for WithoutDealloc<A>
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Attempts to allocate a block of memory. Read more
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Behaves like
allocate
, but also ensures that the returned memory is zero-initialized. Read moreSource§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
Deallocates the memory referenced by
ptr
. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Attempts to extend the memory block. Read more
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Behaves like
grow
, but also ensures that the new contents are set to zero before being
returned. Read moreSource§impl<B: BumpAllocator> BumpAllocator for WithoutDealloc<B>
impl<B: BumpAllocator> BumpAllocator for WithoutDealloc<B>
Source§fn any_stats(&self) -> AnyStats<'_>
fn any_stats(&self) -> AnyStats<'_>
Returns a type which provides statistics about the memory usage of the bump allocator.
Source§fn checkpoint(&self) -> Checkpoint
fn checkpoint(&self) -> Checkpoint
Creates a checkpoint of the current bump position. Read more
Source§unsafe fn reset_to(&self, checkpoint: Checkpoint)
unsafe fn reset_to(&self, checkpoint: Checkpoint)
Resets the bump position to a previously created checkpoint.
The memory that has been allocated since then will be reused by future allocations. Read more
Source§fn prepare_allocation(
&self,
layout: Layout,
) -> Result<Range<NonNull<u8>>, AllocError>
fn prepare_allocation( &self, layout: Layout, ) -> Result<Range<NonNull<u8>>, AllocError>
Returns a pointer range of free space in the bump allocator with a size of at least
layout.size()
. Read moreSource§impl<B: BumpAllocatorExt> BumpAllocatorExt for WithoutDealloc<B>
impl<B: BumpAllocatorExt> BumpAllocatorExt for WithoutDealloc<B>
Source§type Stats<'b> = <B as BumpAllocatorExt>::Stats<'b>
where
Self: 'b
type Stats<'b> = <B as BumpAllocatorExt>::Stats<'b> where Self: 'b
The type returned by the stats method.
Source§fn stats(&self) -> Self::Stats<'_>
fn stats(&self) -> Self::Stats<'_>
Returns a type which provides statistics about the memory usage of the bump allocator.
Source§fn try_allocate_layout(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
fn try_allocate_layout(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
Source§fn try_allocate_sized<T>(&self) -> Result<NonNull<T>, AllocError>
fn try_allocate_sized<T>(&self) -> Result<NonNull<T>, AllocError>
Source§fn allocate_slice<T>(&self, len: usize) -> NonNull<T>
fn allocate_slice<T>(&self, len: usize) -> NonNull<T>
Source§fn try_allocate_slice<T>(&self, len: usize) -> Result<NonNull<T>, AllocError>
fn try_allocate_slice<T>(&self, len: usize) -> Result<NonNull<T>, AllocError>
Source§unsafe fn shrink_slice<T>(
&self,
ptr: NonNull<T>,
old_len: usize,
new_len: usize,
) -> Option<NonNull<T>>
unsafe fn shrink_slice<T>( &self, ptr: NonNull<T>, old_len: usize, new_len: usize, ) -> Option<NonNull<T>>
Source§fn prepare_slice_allocation<T>(&self, len: usize) -> NonNull<[T]>
fn prepare_slice_allocation<T>(&self, len: usize) -> NonNull<[T]>
A specialized version of
prepare_allocation
. Read moreSource§fn try_prepare_slice_allocation<T>(
&self,
len: usize,
) -> Result<NonNull<[T]>, AllocError>
fn try_prepare_slice_allocation<T>( &self, len: usize, ) -> Result<NonNull<[T]>, AllocError>
A specialized version of
prepare_allocation
. Read moreSource§unsafe fn allocate_prepared_slice<T>(
&self,
ptr: NonNull<T>,
len: usize,
cap: usize,
) -> NonNull<[T]>
unsafe fn allocate_prepared_slice<T>( &self, ptr: NonNull<T>, len: usize, cap: usize, ) -> NonNull<[T]>
A specialized version of
allocate_prepared
. Read moreSource§unsafe fn allocate_prepared_slice_rev<T>(
&self,
ptr: NonNull<T>,
len: usize,
cap: usize,
) -> NonNull<[T]>
unsafe fn allocate_prepared_slice_rev<T>( &self, ptr: NonNull<T>, len: usize, cap: usize, ) -> NonNull<[T]>
A specialized version of
allocate_prepared_rev
. Read moreSource§impl<A: Clone> Clone for WithoutDealloc<A>
impl<A: Clone> Clone for WithoutDealloc<A>
Source§fn clone(&self) -> WithoutDealloc<A>
fn clone(&self) -> WithoutDealloc<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<A: Debug> Debug for WithoutDealloc<A>
impl<A: Debug> Debug for WithoutDealloc<A>
Source§impl<A: Default> Default for WithoutDealloc<A>
impl<A: Default> Default for WithoutDealloc<A>
Source§fn default() -> WithoutDealloc<A>
fn default() -> WithoutDealloc<A>
Returns the “default value” for a type. Read more
Source§impl<A: Hash> Hash for WithoutDealloc<A>
impl<A: Hash> Hash for WithoutDealloc<A>
Source§impl<A: Ord> Ord for WithoutDealloc<A>
impl<A: Ord> Ord for WithoutDealloc<A>
Source§fn cmp(&self, other: &WithoutDealloc<A>) -> Ordering
fn cmp(&self, other: &WithoutDealloc<A>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<A: PartialEq> PartialEq for WithoutDealloc<A>
impl<A: PartialEq> PartialEq for WithoutDealloc<A>
Source§impl<A: PartialOrd> PartialOrd for WithoutDealloc<A>
impl<A: PartialOrd> PartialOrd for WithoutDealloc<A>
impl<'a, B: BumpAllocatorScope<'a>> BumpAllocatorScope<'a> for WithoutDealloc<B>
impl<A: Copy> Copy for WithoutDealloc<A>
impl<A: Eq> Eq for WithoutDealloc<A>
impl<A: MutBumpAllocator> MutBumpAllocator for WithoutDealloc<A>
impl<A> StructuralPartialEq for WithoutDealloc<A>
Auto Trait Implementations§
impl<A> Freeze for WithoutDealloc<A>where
A: Freeze,
impl<A> RefUnwindSafe for WithoutDealloc<A>where
A: RefUnwindSafe,
impl<A> Send for WithoutDealloc<A>where
A: Send,
impl<A> Sync for WithoutDealloc<A>where
A: Sync,
impl<A> Unpin for WithoutDealloc<A>where
A: Unpin,
impl<A> UnwindSafe for WithoutDealloc<A>where
A: UnwindSafe,
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