pub struct OrderedPoolAllocator<'buf, T, const N: usize = { mem::size_of::<usize>() }> { /* private fields */ }Expand description
An allocator for T objects, with a block index of N bytes.
Implementations§
Source§impl<'buf, T, const N: usize> OrderedPoolAllocator<'buf, T, N>
impl<'buf, T, const N: usize> OrderedPoolAllocator<'buf, T, N>
pub fn new_in(buf: &'buf mut [u8]) -> Self
Sourcepub unsafe fn allocate(&mut self) -> Result<NonNull<T>, AllocError>
pub unsafe fn allocate(&mut self) -> Result<NonNull<T>, AllocError>
Allocates a block and returns a pointer to the block.
This method will always prioritize reallocating an existing deallocated block over allocating a new block.
§Safety
Behavior is undefined if the returned pointer points to an uninitialized instance of T when the allocator is
dropped.
Sourcepub unsafe fn deallocate(&mut self, ptr: NonNull<T>)
pub unsafe fn deallocate(&mut self, ptr: NonNull<T>)
Deallocates the block at the specified pointer.
Side effect: swaps the virtual block indices of the specified block with the last allocated virtual block.
§Safety
Behavior is undefined if any of the following conditions are violated:
ptrmust point to an instance ofTallocated by this allocator.ptrmust not point to an instance ofTthat has already been dropped or deallocated by this allocator.
pub const fn len(&self) -> usize
pub const fn capacity(&self) -> usize
pub const fn is_empty(&self) -> bool
pub const fn is_full(&self) -> bool
pub fn sort_unstable_by<F>(&mut self, compare: F)
Trait Implementations§
Source§impl<T, const N: usize> Drop for OrderedPoolAllocator<'_, T, N>
impl<T, const N: usize> Drop for OrderedPoolAllocator<'_, T, N>
Auto Trait Implementations§
impl<'buf, T, const N: usize> Freeze for OrderedPoolAllocator<'buf, T, N>
impl<'buf, T, const N: usize> RefUnwindSafe for OrderedPoolAllocator<'buf, T, N>where
T: RefUnwindSafe,
impl<'buf, T, const N: usize = { mem::size_of::<usize>() }> !Send for OrderedPoolAllocator<'buf, T, N>
impl<'buf, T, const N: usize = { mem::size_of::<usize>() }> !Sync for OrderedPoolAllocator<'buf, T, N>
impl<'buf, T, const N: usize> Unpin for OrderedPoolAllocator<'buf, T, N>
impl<'buf, T, const N: usize> UnwindSafe for OrderedPoolAllocator<'buf, T, N>where
T: RefUnwindSafe,
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