#[repr(transparent)]pub struct AllocatorApi2V03Compat<A: ?Sized>(pub A);
Available on crate feature
allocator-api2-03
only.Expand description
Wraps an allocator_api2::alloc::Allocator
to implement
bump_scope::alloc::Allocator
and vice versa.
§Example
use allocator_api2::alloc::Allocator;
use bump_scope::{Bump, alloc::compat::AllocatorApi2V03Compat};
#[derive(Clone)]
struct MyAllocatorApi2Allocator;
unsafe impl Allocator for MyAllocatorApi2Allocator {
...
}
let bump: Bump<_> = Bump::new_in(AllocatorApi2V03Compat(MyAllocatorApi2Allocator));
Tuple Fields§
§0: A
Implementations§
Trait Implementations§
Source§impl<A: ?Sized + Allocator> Allocator for AllocatorApi2V03Compat<A>
impl<A: ?Sized + Allocator> Allocator for AllocatorApi2V03Compat<A>
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, CrateAllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, CrateAllocError>
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§fn allocate_zeroed(
&self,
layout: Layout,
) -> Result<NonNull<[u8]>, CrateAllocError>
fn allocate_zeroed( &self, layout: Layout, ) -> Result<NonNull<[u8]>, CrateAllocError>
Behaves like
allocate
, but also ensures that the returned memory is zero-initialized. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, CrateAllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, CrateAllocError>
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]>, CrateAllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, CrateAllocError>
Behaves like
grow
, but also ensures that the new contents are set to zero before being
returned. Read moreSource§impl<A: ?Sized + CrateAllocator> Allocator for AllocatorApi2V03Compat<A>
impl<A: ?Sized + CrateAllocator> Allocator for AllocatorApi2V03Compat<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§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§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 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<A: Clone + ?Sized> Clone for AllocatorApi2V03Compat<A>
impl<A: Clone + ?Sized> Clone for AllocatorApi2V03Compat<A>
Source§fn clone(&self) -> AllocatorApi2V03Compat<A>
fn clone(&self) -> AllocatorApi2V03Compat<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 moreAuto Trait Implementations§
impl<A> Freeze for AllocatorApi2V03Compat<A>
impl<A> RefUnwindSafe for AllocatorApi2V03Compat<A>where
A: RefUnwindSafe + ?Sized,
impl<A> Send for AllocatorApi2V03Compat<A>
impl<A> Sync for AllocatorApi2V03Compat<A>
impl<A> Unpin for AllocatorApi2V03Compat<A>
impl<A> UnwindSafe for AllocatorApi2V03Compat<A>where
A: UnwindSafe + ?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