pub struct Interner { /* private fields */ }Expand description
The table of names for one run. Thread-safe; share it with an Arc.
Tokens are assigned in insertion order, starting at 0. To reproduce TLC’s order of strings, model values and record fields, intern names in the order SANY and TLC first meet them.
use dive_value::Interner;
let names = Interner::new();
let b = names.intern("b");
let a = names.intern("a");
assert!(b.tok() < a.tok());
assert_eq!(names.intern("b"), b);Implementations§
Source§impl Interner
impl Interner
Sourcepub fn intern(&self, text: &str) -> Atom
pub fn intern(&self, text: &str) -> Atom
Returns the atom for text, interning it with the next token if it is new.
Sourcepub fn resolve(&self, tok: u32) -> Option<Atom>
pub fn resolve(&self, tok: u32) -> Option<Atom>
Returns the atom with token tok, if one has been interned.
This is the inverse of Atom::tok for this table. State encodings store
names by token (crate::codec), and decoding resolves them here.
use dive_value::Interner;
let names = Interner::new();
let a = names.intern("a");
assert_eq!(names.resolve(a.tok()), Some(a));
assert_eq!(names.resolve(7), None);Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Interner
impl Forget for Interner
impl Move for Interner
impl RefUnwindSafe for Interner
impl Send for Interner
impl Sync for Interner
impl Unpin for Interner
impl UnsafeUnpin for Interner
impl UnwindSafe for Interner
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