Struct cstree::NodeCache [−][src]
A NodeCache
deduplicates identical tokens and small nodes during tree construction.
You can re-use the same cache for multiple similar trees with GreenNodeBuilder::with_cache
.
Implementations
impl NodeCache<'static>
[src]
pub fn new() -> Self
[src]
Constructs a new, empty cache.
By default, this will also create a default interner to deduplicate source text (strings) across
tokens. To re-use an existing interner, see with_interner
.
Examples
let mut cache = NodeCache::new(); let mut builder = GreenNodeBuilder::with_cache(&mut cache); parse(&mut builder, "42"); let (tree, _) = builder.finish(); assert_eq!(tree.kind(), ROOT); let int = tree.children().next().unwrap(); assert_eq!(int.kind(), INT);
impl<'i, I> NodeCache<'i, I> where
I: Interner,
[src]
I: Interner,
pub fn with_interner(interner: &'i mut I) -> Self
[src]
Constructs a new, empty cache that will use the given interner to deduplicate source text (strings) across tokens.
Examples
use lasso::Rodeo; let mut interner = Rodeo::new(); let mut cache = NodeCache::with_interner(&mut interner); let mut builder = GreenNodeBuilder::with_cache(&mut cache); parse(&mut builder, "42"); let (tree, _) = builder.finish(); assert_eq!(tree.kind(), ROOT); let int = tree.children().next().unwrap(); assert_eq!(int.kind(), INT);
Trait Implementations
Auto Trait Implementations
impl<'i, I> RefUnwindSafe for NodeCache<'i, I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
impl<'i, I> Send for NodeCache<'i, I> where
I: Send,
I: Send,
impl<'i, I> Sync for NodeCache<'i, I> where
I: Sync,
I: Sync,
impl<'i, I> Unpin for NodeCache<'i, I> where
I: Unpin,
I: Unpin,
impl<'i, I = TokenInterner> !UnwindSafe for NodeCache<'i, I>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,