Struct fixed_bump::Rc
source · pub struct Rc<Bump>(pub Rc<Bump>);
Expand description
A wrapper around Rc
.
This type exists mainly so that Allocator
can be implemented for it:
use fixed_bump::Bump;
let rc = std::rc::Rc::new(Bump::<[u32; 16]>::new());
// Error: `std::rc::Rc<Bump<...>>` doesn't implement `Allocator`:
//let b = Box::new_in(1_u32, rc);
// Compiles: `fixed_bump::Rc<Bump<...>>` implements `Allocator`:
let b = Box::new_in(1_u32, fixed_bump::Rc(rc));
Tuple Fields§
§0: Rc<Bump>
Implementations§
Trait Implementations§
source§impl<Bump: Allocator> Allocator for Rc<Bump>
Available on crate features allocator_api
or allocator-fallback
only.
impl<Bump: Allocator> Allocator for Rc<Bump>
Available on crate features
allocator_api
or allocator-fallback
only.source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)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)
🔬This is a nightly-only experimental API. (
allocator_api
)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>
🔬This is a nightly-only experimental API. (
allocator_api
)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>
🔬This is a nightly-only experimental API. (
allocator_api
)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>
🔬This is a nightly-only experimental API. (
allocator_api
)Behaves like
grow
, but also ensures that the new contents are set to zero before being
returned. Read more