Skip to main content

ArenaSlice

Struct ArenaSlice 

Source
pub struct ArenaSlice<T> { /* private fields */ }
Expand description

Interning arena for slices of type T.

Implementations§

Source§

impl<T> ArenaSlice<T>

Source

pub fn with_capacity(slices: usize, items: usize) -> Self

Creates a new arena with pre-allocated space to store at least the given number of slices, totalling the given number of items of type T.

Source

pub fn slices(&self) -> usize

Returns the number of slices in this arena.

Note that because ArenaSlice is a concurrent data structure, this is only a snapshot as viewed by this thread, and the result may change if other threads are inserting values.

Source

pub fn items(&self) -> usize

Returns the total number of items of type T in this arena.

Note that because ArenaSlice is a concurrent data structure, this is only a snapshot as viewed by this thread, and the result may change if other threads are inserting values.

Source

pub fn is_empty(&self) -> bool

Checks if this arena is empty.

Note that because ArenaSlice is a concurrent data structure, this is only a snapshot as viewed by this thread, and the result may change if other threads are inserting values.

Source§

impl<T> ArenaSlice<T>
where T: Eq + Hash,

Source

pub fn find(&self, value: &[T]) -> Option<InternedSlice<T>>

Returns the given value’s InternedSlice handle if it is already interned.

Otherwise, this simply returns None without adding the value to this arena.

Source§

impl<T> ArenaSlice<T>
where T: GetSize,

Source

pub fn print_summary(&self, prefix: &str, title: &str, total_bytes: usize)

Available on crate feature debug only.

Prints a summary of the storage used by this arena to stdout.

Source§

impl<T> ArenaSlice<T>
where T: Default + Eq + Hash,

Source

pub fn intern_owned(&self, value: Vec<T>) -> InternedSlice<T>

Interns the given value in this arena.

If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.

Source

pub fn intern_array<const N: usize>(&self, value: [T; N]) -> InternedSlice<T>

Interns the given value in this arena.

If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.

Source

pub fn push_owned_mut(&mut self, value: Vec<T>) -> InternedSlice<T>

Available on crate feature raw only.

Unconditionally push a value, without validating that it’s already interned.

Source

pub fn push_array_mut<const N: usize>( &mut self, value: [T; N], ) -> InternedSlice<T>

Available on crate feature raw only.

Unconditionally push a value, without validating that it’s already interned.

Source§

impl<T> ArenaSlice<T>
where T: Default + Clone + Eq + Hash,

Source

pub fn intern(&self, value: &[T]) -> InternedSlice<T>

Interns the given value in this arena.

If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.

If T is Copy, it may be more efficient to call intern_copy() instead.

Source

pub fn push_mut(&mut self, value: &[T]) -> u32

Available on crate feature raw only.

Unconditionally push a value, without validating that it’s already interned.

If T is Copy, calling push_copy_mut() may be more efficient.

Source§

impl<T> ArenaSlice<T>
where T: Default + Copy + Eq + Hash,

Source

pub fn intern_copy(&self, value: &[T]) -> InternedSlice<T>

Interns the given value in this arena.

If the value was already interned in this arena, its interning index will simply be returned. Otherwise it will be stored into the arena.

If T is only Clone, you can call intern() instead. If T is also not Clone, you can call intern_owned() or intern_array().

Source

pub fn push_copy_mut(&mut self, value: &[T]) -> u32

Available on crate feature raw only.

Unconditionally push a value, without validating that it’s already interned.

If T is only Clone, you can call push_mut() instead.

Source§

impl<T> ArenaSlice<T>

Source

pub fn lookup(&self, interned: InternedSlice<T>) -> &[T]

Retrieves the given InternedSlice value from this arena.

The caller is responsible for ensuring that the same arena was used to intern this value, otherwise an arbitrary value will be returned or a panic will happen.

Trait Implementations§

Source§

impl<T> Clone for ArenaSlice<T>
where T: Default + Clone + Eq + Hash,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for ArenaSlice<T>
where T: Debug,

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for ArenaSlice<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for ArenaSlice<T>
where T: Default + Clone + Eq + Hash + Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> GetSize for ArenaSlice<T>
where T: GetSize,

Available on crate feature get-size2 only.
Source§

fn get_heap_size_with_tracker<Tr: GetSizeTracker>( &self, tracker: Tr, ) -> (usize, Tr)

Determines how many bytes this object occupies inside the heap while using a tracker. Read more
Source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
Source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
Source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
Source§

fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)
where T: GetSizeTracker,

Determines the total size of the object while using a tracker. Read more
Source§

impl<T> PartialEq for ArenaSlice<T>
where T: Eq + Hash,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for ArenaSlice<T>
where T: Serialize,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Eq for ArenaSlice<T>
where T: Eq + Hash,

Auto Trait Implementations§

§

impl<T> !Freeze for ArenaSlice<T>

§

impl<T> !RefUnwindSafe for ArenaSlice<T>

§

impl<T> Send for ArenaSlice<T>
where T: Send + Sync,

§

impl<T> Sync for ArenaSlice<T>
where T: Send + Sync,

§

impl<T> Unpin for ArenaSlice<T>

§

impl<T> UnsafeUnpin for ArenaSlice<T>

§

impl<T> UnwindSafe for ArenaSlice<T>
where T: RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,