pub struct NoOpAllocator;Expand description
An allocator that does not perform any actual allocation or deallocation.
This is useful when constructing Box and other dynamically allocated collections from raw pointers to pre-existing memory that is owned and managed elsewhere (e.g., by C++ code), to ensure that dropping the collection does not deallocate the underlying memory.
Trait Implementations§
Source§impl Allocator for NoOpAllocator
impl Allocator for NoOpAllocator
Source§fn allocate(&self, _layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, _layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Allocates memory as described by the given
layout. 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>
Safety Read more
Source§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>
Safety Read more
Source§fn allocate_zeroed(&self, _layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, _layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Allocates zeroed memory as described by the given
layout. Read moreSource§impl Clone for NoOpAllocator
impl Clone for NoOpAllocator
Source§fn clone(&self) -> NoOpAllocator
fn clone(&self) -> NoOpAllocator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for NoOpAllocator
impl Default for NoOpAllocator
Source§fn default() -> NoOpAllocator
fn default() -> NoOpAllocator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for NoOpAllocator
impl RefUnwindSafe for NoOpAllocator
impl Send for NoOpAllocator
impl Sync for NoOpAllocator
impl Unpin for NoOpAllocator
impl UnsafeUnpin for NoOpAllocator
impl UnwindSafe for NoOpAllocator
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