pub struct Interner { /* private fields */ }Expand description
The owner of every Symbol.
The interner is an explicit handle rather than a thread-local or a process
global. Two consequences are worth the extra parameter: a Symbol is
meaningful only against the interner that made it, which is a fact the type
system can be made to carry, and nothing in this workspace acquires hidden
shared state to resolve a name.
Implementations§
Source§impl Interner
impl Interner
Sourcepub fn intern(&mut self, text: &str) -> Symbol
pub fn intern(&mut self, text: &str) -> Symbol
Returns the symbol for text, interning it if it is new.
§Panics
Panics when the interner already holds u32::MAX + 1 distinct
identifiers, more than any source map can hold.
Sourcepub fn resolve(&self, symbol: Symbol) -> &str
pub fn resolve(&self, symbol: Symbol) -> &str
Returns the text symbol names.
§Panics
Panics when symbol came from a different interner, which is a defect
rather than a condition to recover from.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Interner
impl Freeze 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 Internerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Arc<str>>: UnsafeUnpin,
PhantomData<(Arc<str>, Symbol)>: UnsafeUnpin,
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