Struct SliceArena

Source
pub struct SliceArena<T = u8> { /* private fields */ }
Expand description

Thread-safe memory arena.

Implementations§

Source§

impl<T: Clone> SliceArena<T>

Source

pub fn new() -> Self

New arena with ~64KB of initial capacity (which will grow exponentially as needed).

It works with any cloneable element type, but SliceArena<u8> is the default (it’s like Vec<u8>).

Source

pub fn with_capacity(capacity: usize) -> Self

New arena with memory reserved for the initial number of elements.

Arena grows expomnentially, so once this capacity is exhausted, a double of that size will be allocated.

Capacity should be much much larger than sizes of slices pushed. Pushing a slice larger than the capacity leaves previous capacity unused.

Source

pub fn push<'arena>(&'arena self, slice: &[T]) -> &'arena mut [T]

Copy a slice into the arena. Returns arena-allocated slice.

Source§

impl SliceArena<u8>

Source

pub fn push_str<'arena>(&'arena self, s: impl AsRef<str>) -> &'arena str

Store a string slice in the arena.

Source

pub fn push_os_str<'arena>(&'arena self, s: &OsStr) -> &'arena OsStr

Store a Unix OsStr in the arena. This function does not exist on Windows.

Source

pub fn push_path<'arena>(&'arena self, str: impl AsRef<Path>) -> &'arena Path

Store a Unix Path in the arena. This function does not exist on Windows.

Auto Trait Implementations§

§

impl<T = u8> !Freeze for SliceArena<T>

§

impl<T> RefUnwindSafe for SliceArena<T>

§

impl<T> Send for SliceArena<T>
where T: Send,

§

impl<T> Sync for SliceArena<T>
where T: Send,

§

impl<T> Unpin for SliceArena<T>
where T: Unpin,

§

impl<T> UnwindSafe for SliceArena<T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.