Struct rustc_arena::DroplessArena
source · pub struct DroplessArena {
pub(crate) start: Cell<*mut u8>,
pub(crate) end: Cell<*mut u8>,
pub(crate) chunks: RefCell<Vec<ArenaChunk>>,
}
Expand description
An arena that can hold objects of multiple different types that impl Copy
and/or satisfy !mem::needs_drop
.
Fields
start: Cell<*mut u8>
A pointer to the start of the free space.
end: Cell<*mut u8>
A pointer to the end of free space.
The allocation proceeds downwards from the end of the chunk towards the start. (This is slightly simpler and faster than allocating upwards, see https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html.) When this pointer crosses the start pointer, a new chunk is allocated.
chunks: RefCell<Vec<ArenaChunk>>
A vector of arena chunks.
Implementations
sourceimpl DroplessArena
impl DroplessArena
pub(crate) fn grow(&self, additional: usize)
sourcepub(crate) fn alloc_raw_without_grow(&self, layout: Layout) -> Option<*mut u8>
pub(crate) fn alloc_raw_without_grow(&self, layout: Layout) -> Option<*mut u8>
Allocates a byte slice with specified layout from the current memory
chunk. Returns None
if there is no free space left to satisfy the
request.
pub fn alloc_raw(&self, layout: Layout) -> *mut u8
pub fn alloc<T>(&self, object: T) -> &mut T
sourcepub fn alloc_slice<T>(&self, slice: &[T]) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
where
T: Copy,
pub fn alloc_slice<T>(&self, slice: &[T]) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
where
T: Copy,
Allocates a slice of objects that are copied into the DroplessArena
, returning a mutable
reference to it. Will panic if passed a zero-sized type.
Panics:
- Zero-sized types
- Zero-length slices
pub(crate) unsafe fn write_from_iter<T, I: Iterator<Item = T>>(
&self,
iter: I,
len: usize,
mem: *mut T
) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn alloc_from_iter<T, I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Trait Implementations
sourceimpl Default for DroplessArena
impl Default for DroplessArena
sourcefn default() -> DroplessArena
fn default() -> DroplessArena
impl Send for DroplessArena
Auto Trait Implementations
impl !RefUnwindSafe for DroplessArena
impl !Sync for DroplessArena
impl Unpin for DroplessArena
impl UnwindSafe for DroplessArena
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes