Struct Arena
pub(crate) struct Arena { pub(in ::bridge::arena) start: Cell<*mut MaybeUninit<u8>>, pub(in ::bridge::arena) end: Cell<*mut MaybeUninit<u8>>, pub(in ::bridge::arena) chunks: RefCell<Vec<Box<[MaybeUninit<u8>]>>> }
A minimal arena allocator inspired by rustc_arena::DroplessArena.
This is unfortunately a complete re-implementation rather than a dependency
as it is difficult to depend on crates from within proc_macro, due to it
being built at the same time as std.
This arena doesn't have support for allocating anything other than byte slices, as that is all that is necessary.
Fields
start: Cell<*mut MaybeUninit<u8>>end: Cell<*mut MaybeUninit<u8>>chunks: RefCell<Vec<Box<[MaybeUninit<u8>]>>>
Implementations
impl Arena
fn new() -> Selffn grow(&self, additional: usize)Add a new chunk with at least
additionalfree bytes.fn alloc_raw_without_grow(&self, bytes: usize) -> Option<&mut [MaybeUninit<u8>]>Allocates a byte slice with specified size from the current memory chunk. Returns
Noneif there is no free space left to satisfy the request.fn alloc_raw(&self, bytes: usize) -> &mut [MaybeUninit<u8>]fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str
Auto Trait Implementations
impl !Freeze for Arena
impl !RefUnwindSafe for Arena
impl !Send for Arena
impl !Sync for Arena
impl Unpin for Arena
impl UnsafeUnpin for Arena
impl UnwindSafe for Arena
Blanket Implementations
impl<T> Any for Arena
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Arena
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Arena
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Arena
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for Arena
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for Arena
impl<T, U> Into<U> for Arena
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Arena
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Arena
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>