pub struct HashConsArena<T> { /* private fields */ }Expand description
A hash consing arena that allows for efficient interning of values.
§Caveat(s)
The arena is backed by a bumpalo, therefore, objects
allocated via the arena, will not have their Drop implementation called, without manual
intervention. Thus, it is relatively easy to leak resources. If you need Drop to be called,
use BoxedHashConsArena instead.
Implementations§
Source§impl<T> HashConsArena<T>
impl<T> HashConsArena<T>
Sourcepub fn intern<'a>(&'a self, value: T) -> HRef<'a, T>where
T: Debug,
pub fn intern<'a>(&'a self, value: T) -> HRef<'a, T>where
T: Debug,
Intern a value, returning a reference that’s guaranteed to be the same for structurally equal values.
§Arguments
value- The value to intern. It must implementEqandHash.
§Returns
A HRef<T> that points to the interned value. If the value is already interned, it returns
the existing reference.
§Example
ⓘ
use hashcons_arena::HashConsArena;
let arena = HashConsArena::new();
let a = arena.intern("hello");
let b = arena.intern("hello");
assert!(a == b); // a and b are the same referenceAuto Trait Implementations§
impl<T> !Freeze for HashConsArena<T>
impl<T> !RefUnwindSafe for HashConsArena<T>
impl<T> !Send for HashConsArena<T>
impl<T> !Sync for HashConsArena<T>
impl<T> !UnwindSafe for HashConsArena<T>
impl<T> Unpin for HashConsArena<T>
impl<T> UnsafeUnpin for HashConsArena<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more