Struct proc_macro::bridge::arena::Arena

source ·
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

source

pub(crate) fn new() -> Self

🔬This is a nightly-only experimental API. (proc_macro_internals #27812)
source

fn grow(&self, additional: usize)

🔬This is a nightly-only experimental API. (proc_macro_internals #27812)

Add a new chunk with at least additional free bytes.

source

fn alloc_raw_without_grow(&self, bytes: usize) -> Option<&mut [MaybeUninit<u8>]>

🔬This is a nightly-only experimental API. (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.

source

fn alloc_raw(&self, bytes: usize) -> &mut [MaybeUninit<u8>]

🔬This is a nightly-only experimental API. (proc_macro_internals #27812)
source

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 !RefUnwindSafe for Arena

§

impl !Send for Arena

§

impl !Sync for Arena

§

impl Unpin for Arena

§

impl UnwindSafe for Arena

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.