Struct bones_lib::prelude::bones_schema::alloc::ResizableAlloc
pub struct ResizableAlloc { /* private fields */ }
Expand description
A low-level memory allocation utility for creating a resizable buffer of elements of a specific layout.
The allocation has a capacity measured in the number of elements with the given Layout
that
it has room for.
Dropping a ResizableAlloc
will de-allocate it’s memory.
Implementations§
§impl ResizableAlloc
impl ResizableAlloc
pub fn new(layout: Layout) -> ResizableAlloc
pub fn new(layout: Layout) -> ResizableAlloc
Create a new ResizableAlloc
for the given memory layout. Does not actually allocate
anything yet.hing.
If the new capacity is greater, it will reallocate and extend the allocated region to be
able to fit new_capacity
items of the this ResizableAlloc
’s layout.
If the new capacity is lower, it will reallocate and remove all items
The capacity will be 0 and the pointer will be dangling.
§Panics
Panics if the provided layout is not already padded to it’s alignment.
pub fn with_capacity(
layout: Layout,
capacity: usize,
) -> Result<ResizableAlloc, LayoutError>
pub fn with_capacity( layout: Layout, capacity: usize, ) -> Result<ResizableAlloc, LayoutError>
Create a new ResizableAlloc
with the given capacity.
pub fn resize(&mut self, new_capacity: usize) -> Result<(), LayoutError>
pub fn resize(&mut self, new_capacity: usize) -> Result<(), LayoutError>
Resize the buffer, re-allocating it’s memory.
pub fn iter(&self) -> ResizableAllocIter<'_> ⓘ
pub fn iter(&self) -> ResizableAllocIter<'_> ⓘ
Iterate over the allocation.
pub fn iter_mut(&mut self) -> ResizableAllocIterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> ResizableAllocIterMut<'_> ⓘ
Iterate mutably over the allocation.
pub unsafe fn unchecked_idx(&self, idx: usize) -> *mut c_void
pub unsafe fn unchecked_idx(&self, idx: usize) -> *mut c_void
Get a pointer to the item with the given index without performing any bounds checks.
§Safety
This does no checks that the index is within bounds or that the returne dpointer is unaliased.
Trait Implementations§
§impl Clone for ResizableAlloc
impl Clone for ResizableAlloc
§fn clone(&self) -> ResizableAlloc
fn clone(&self) -> ResizableAlloc
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ResizableAlloc
impl Debug for ResizableAlloc
Auto Trait Implementations§
impl Freeze for ResizableAlloc
impl RefUnwindSafe for ResizableAlloc
impl !Send for ResizableAlloc
impl !Sync for ResizableAlloc
impl Unpin for ResizableAlloc
impl UnwindSafe for ResizableAlloc
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)