pub trait NodePredicate<Ctx>: Send + Sync {
// Required method
fn test(&self, input: Input<'_, Ctx>) -> bool;
}Expand description
A predicate over an Input — returns true when the node matches.
Any F: Fn(Input<'_, Ctx>) -> bool + Send + Sync implements this trait
automatically via the blanket implementation, so plain closures work too.
Use the free-function constructors (kind_is, kind_is_not, …) to
obtain named predicate values, or supply any compatible closure directly.
§Example
use tree_sitter_utils::{NodePredicate, kind_is};
fn accepts_pred<Ctx: Copy, P: NodePredicate<Ctx>>(_: P) {}
accepts_pred::<(), _>(kind_is(&["identifier"]));
accepts_pred::<(), _>(|input: tree_sitter_utils::Input<()>| input.node.kind() == "identifier");Required Methods§
Implementors§
impl<Ctx> NodePredicate<Ctx> for HasAncestorKind
impl<Ctx> NodePredicate<Ctx> for HasAncestorKinds
impl<Ctx> NodePredicate<Ctx> for HasParentKind
impl<Ctx> NodePredicate<Ctx> for KindIs
impl<Ctx> NodePredicate<Ctx> for KindIsNot
impl<Ctx> NodePredicate<Ctx> for NodeDepthLte
impl<Ctx, F> NodePredicate<Ctx> for F
Blanket impl: every Fn(Input<'_, Ctx>) -> bool + Send + Sync is a predicate.