Trait xalloc::arena::UnsafeArena
source · pub trait UnsafeArena<T> {
type Ptr: Debug + Clone + Default + PartialEq + Eq;
fn insert(&mut self, x: T) -> Self::Ptr;
unsafe fn get_unchecked(&self, ptr: &Self::Ptr) -> &T;
unsafe fn get_unchecked_mut(&mut self, ptr: &Self::Ptr) -> &mut T;
unsafe fn remove_unchecked(&mut self, ptr: &Self::Ptr) -> T;
fn reserve(&mut self, _additional: usize) { ... }
}
Expand description
Homogeneous memory arena types supporting operations that do not guarantee memory safety.
Methods prefixed with _unchecked
all assume given pointers are valid;
specifically, they assumes that:
- The pointers were constructed by the same instance of
UnsafeArena
. - The pointers have not been removed from the arena yet.
Required Associated Types
sourcetype Ptr: Debug + Clone + Default + PartialEq + Eq
type Ptr: Debug + Clone + Default + PartialEq + Eq
Pointer type.
Ptr::clone(p)
returns a pointer that points the same object.Ptr::default()
returns an uninitialized pointer with a well-defined value (e.g., null pointer).Ptr::eq(x, y)
checks the equality of two pointers. Both pointers must originate from the same arena. Otherwise, the returned value does not make sense.
Required Methods
sourcefn insert(&mut self, x: T) -> Self::Ptr
fn insert(&mut self, x: T) -> Self::Ptr
Insert a value into the arena.
Returns a pointer that points the inserted value.
sourceunsafe fn get_unchecked(&self, ptr: &Self::Ptr) -> &T
unsafe fn get_unchecked(&self, ptr: &Self::Ptr) -> &T
Get a reference to a contained value, without a pointer validity check.
sourceunsafe fn get_unchecked_mut(&mut self, ptr: &Self::Ptr) -> &mut T
unsafe fn get_unchecked_mut(&mut self, ptr: &Self::Ptr) -> &mut T
Get a mutable reference to a contained value, without a pointer validity check.
sourceunsafe fn remove_unchecked(&mut self, ptr: &Self::Ptr) -> T
unsafe fn remove_unchecked(&mut self, ptr: &Self::Ptr) -> T
Remove a value from the arena, without a pointer validity check.
Returns the removed value.