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)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)end: Cell<*mut MaybeUninit<u8>>🔬This is a nightly-only experimental API. (
§proc_macro_internals)chunks: RefCell<Vec<Box<[MaybeUninit<u8>]>>>🔬This is a nightly-only experimental API. (
proc_macro_internals)Implementations§
Source§impl Arena
impl Arena
pub(crate) fn new() -> Self
🔬This is a nightly-only experimental API. (
proc_macro_internals)Sourcefn grow(&self, additional: usize)
🔬This is a nightly-only experimental API. (proc_macro_internals)
fn grow(&self, additional: usize)
proc_macro_internals)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)
fn alloc_raw_without_grow(&self, bytes: usize) -> Option<&mut [MaybeUninit<u8>]>
proc_macro_internals)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)pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str
🔬This is a nightly-only experimental API. (
proc_macro_internals)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§
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> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
🔬This is a nightly-only experimental API. (
core_io_internals)Returns a lower bound on the number of elements this container-like item
contains.
For example, an array
[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type #102070)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