1
Fork 0
mirror of https://github.com/RGBCube/cstree synced 2025-07-27 09:07:44 +00:00

make NodeCache's interner accessible

This commit is contained in:
Domenic Quirl 2021-08-28 11:07:51 +02:00
parent 78e54d59db
commit cc5ea59d4b

View file

@ -133,6 +133,27 @@ where
}
}
/// Get a reference to the interner used to deduplicate source text (strings).
///
/// See also [`interner_mut`](NodeCache::interner_mut).
pub fn interner(&self) -> &I {
&*self.interner
}
/// Get a mutable reference to the interner used to deduplicate source text (strings).
/// # Examples
/// ```
/// # use cstree::*;
/// # use cstree::interning::*;
/// let mut cache = NodeCache::new();
/// let interner = cache.interner_mut();
/// let key = interner.get_or_intern("foo");
/// assert_eq!(interner.resolve(&key), "foo");
/// ```
pub fn interner_mut(&mut self) -> &mut I {
&mut *self.interner
}
/// If this node cache was constructed with [`new`](NodeCache::new) or
/// [`from_interner`](NodeCache::from_interner), returns the interner used to deduplicate source
/// text (strings) to allow resolving tree tokens back to text and re-using the interner to build