Struct fixed_bump::RcBump
source · [−]Expand description
Tuple Fields
0: Rc<Bump<Size, Align>>
Implementations
Methods from Deref<Target = Bump<Size, Align>>
sourcepub fn allocate(&self, layout: Layout) -> Option<NonNull<[u8]>>
pub fn allocate(&self, layout: Layout) -> Option<NonNull<[u8]>>
Tries to allocate memory with a size and alignment matching layout
.
Returns a pointer to the memory on success, or None
on failure.
The memory is valid until the Bump
is dropped. Note that the
returned memory could be larger than layout.size()
.
This method is similar to Allocator::allocate
, except it returns an
Option
instead of a Result
.
Allocation is guaranteed to succeed, assuming the global allocator
succeeds, if layout.size()
is less than or equal to
mem::size_of::<Size>()
and layout.align()
is less than
or equal to mem::align_of::<Align>()
.
Allocation may fail, but is not guaranteed to fail, if
layout.align()
is greater than
mem::align_of::<Align>()
. Allocation is guaranteed to
fail if layout.size()
is greater than
mem::size_of::<Size>()
.
sourcepub fn alloc_value<T>(&self, value: T) -> &mut T
pub fn alloc_value<T>(&self, value: T) -> &mut T
Allocates a value of type T
.
The memory is initialized with value
and a reference to the value is
returned. Note that the value’s destructor will not be called
automatically.
Panics
Panics if Self::allocate
is not able to allocate memory matching
Layout::new::<T>()
. See Self::allocate
for
details regarding the circumstances in which allocation can fail.
For a non-panicking equivalent, see Self::try_alloc_value
.
sourcepub fn try_alloc_value<T>(&self, value: T) -> Result<&mut T, T>
pub fn try_alloc_value<T>(&self, value: T) -> Result<&mut T, T>
Tries to allocate a value of type T
.
If the allocation succeeds, the memory is initialized with value
and
a reference to the value is returned. Note that the value’s destructor
will not be called automatically.
Allocation succeeds if and only if Self::allocate
is able to
allocate memory matching Layout::new::<T>()
. See Self::allocate
for details regarding the circumstances in which allocation can fail.
Errors
If allocation fails, Err(value)
is returned.
Trait Implementations
sourceimpl<Size, Align> Allocator for RcBump<Size, Align>
impl<Size, Align> Allocator for RcBump<Size, Align>
sourcefn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api
)Attempts to allocate a block of memory. Read more
sourceunsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
allocator_api
)Deallocates the memory referenced by ptr
. Read more
sourcefn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api
)Behaves like allocate
, but also ensures that the returned memory is zero-initialized. Read more
sourceunsafe 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>
allocator_api
)Attempts to extend the memory block. Read more
sourceunsafe 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>
allocator_api
)Behaves like grow
, but also ensures that the new contents are set to zero before being
returned. Read more
Auto Trait Implementations
impl<Size, Align = Size> !RefUnwindSafe for RcBump<Size, Align>
impl<Size, Align = Size> !Send for RcBump<Size, Align>
impl<Size, Align = Size> !Sync for RcBump<Size, Align>
impl<Size, Align> Unpin for RcBump<Size, Align>
impl<Size, Align = Size> !UnwindSafe for RcBump<Size, Align>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more