pub(crate) struct Arena {
start: Cell<*mut MaybeUninit<u8>>,
end: Cell<*mut MaybeUninit<u8>>,
chunks: RefCell<Vec<Box<[MaybeUninit<u8>]>>>,
}
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)Expand description
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>>
🔬This is a nightly-only experimental API. (
§proc_macro_internals
#27812)end: Cell<*mut MaybeUninit<u8>>
🔬This is a nightly-only experimental API. (
§proc_macro_internals
#27812)chunks: RefCell<Vec<Box<[MaybeUninit<u8>]>>>
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)Implementations§
Source§impl Arena
impl Arena
pub(crate) fn new() -> Self
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)Sourcefn grow(&self, additional: usize)
🔬This is a nightly-only experimental API. (proc_macro_internals
#27812)
fn grow(&self, additional: usize)
proc_macro_internals
#27812)Add a new chunk with at least additional
free bytes.
Sourcefn alloc_raw_without_grow(&self, bytes: usize) -> Option<&mut [MaybeUninit<u8>]>
🔬This is a nightly-only experimental API. (proc_macro_internals
#27812)
fn alloc_raw_without_grow(&self, bytes: usize) -> Option<&mut [MaybeUninit<u8>]>
proc_macro_internals
#27812)Allocates a byte slice with specified size from the current memory
chunk. Returns None
if there is no free space left to satisfy the
request.
fn alloc_raw(&self, bytes: usize) -> &mut [MaybeUninit<u8>]
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str
🔬This is a nightly-only experimental API. (
proc_macro_internals
#27812)Auto Trait Implementations§
impl !Freeze for Arena
impl !RefUnwindSafe for Arena
impl !Send for Arena
impl !Sync for Arena
impl Unpin for Arena
impl UnwindSafe for Arena
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
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)The largest safe length for a
[Self]
. Read more