Struct cstree::NodeCache[][src]

pub struct NodeCache<'i, I = TokenInterner> { /* fields omitted */ }

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]

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

impl<'i, I: Debug> Debug for NodeCache<'i, I>[src]

impl Default for NodeCache<'static>[src]

Auto Trait Implementations

impl<'i, I> RefUnwindSafe for NodeCache<'i, I> where
    I: RefUnwindSafe

impl<'i, I> Send for NodeCache<'i, I> where
    I: Send

impl<'i, I> Sync for NodeCache<'i, I> where
    I: Sync

impl<'i, I> Unpin for NodeCache<'i, I> where
    I: Unpin

impl<'i, I = TokenInterner> !UnwindSafe for NodeCache<'i, I>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.