Skip to main content

DispatchOnKind

Struct DispatchOnKind 

Source
pub struct DispatchOnKind<Ctx: 'static, R: 'static> {
    pub table: &'static [(&'static str, &'static dyn Handler<Ctx, R>)],
}
Expand description

Handler produced by dispatch_on_kind.

§Example

use tree_sitter_utils::dispatch_on_kind;
let h = dispatch_on_kind::<(), u32>(&[]);
let _ = h;

Fields§

§table: &'static [(&'static str, &'static dyn Handler<Ctx, R>)]

The static dispatch table.

Trait Implementations§

Source§

impl<Ctx, R> Handler<Ctx, R> for DispatchOnKind<Ctx, R>
where Ctx: Copy + 'static, R: 'static,

Source§

fn handle<'tree>(&self, input: Input<'tree, Ctx>) -> HandlerResult<R>

Attempt to produce an output value for the given input. Read more

Auto Trait Implementations§

§

impl<Ctx, R> Freeze for DispatchOnKind<Ctx, R>

§

impl<Ctx, R> !RefUnwindSafe for DispatchOnKind<Ctx, R>

§

impl<Ctx, R> Send for DispatchOnKind<Ctx, R>

§

impl<Ctx, R> Sync for DispatchOnKind<Ctx, R>

§

impl<Ctx, R> Unpin for DispatchOnKind<Ctx, R>

§

impl<Ctx, R> UnsafeUnpin for DispatchOnKind<Ctx, R>

§

impl<Ctx, R> !UnwindSafe for DispatchOnKind<Ctx, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Ctx, R, T> HandlerExt<Ctx, R> for T
where T: Handler<Ctx, R>,

Source§

fn or<H: Handler<Ctx, R>>(self, other: H) -> Or<Self, H>

Try self; if it returns None, try other. Read more
Source§

fn when<P: NodePredicate<Ctx>>(self, pred: P) -> When<Self, P>

Run self only when pred returns true; otherwise return None. Read more
Source§

fn for_kinds(self, kinds: &'static [&'static str]) -> When<Self, KindIs>

Sugar for .when(kind_is(kinds)) - only handle specific node kinds. Read more
Source§

fn map<F, R2>(self, f: F) -> Map<Self, F, R>
where F: Fn(R) -> R2 + Send + Sync,

Apply f to the output value when self succeeds. Read more
Source§

fn map_input<F>(self, f: F) -> MapInput<Self, F>
where F: for<'tree> Fn(Input<'tree, Ctx>) -> Input<'tree, Ctx> + Send + Sync,

Transform the Input before passing it to self. Read more
Source§

fn and_then<F, R2>(self, f: F) -> AndThen<Self, F, R>
where F: Fn(Input<'_, Ctx>, R) -> Option<R2> + Send + Sync,

On success, pass (input, out) to f, which may itself return None. Read more
Source§

fn climb(self, stop_kinds: &'static [&'static str]) -> Climb<Self>

Retry self on each ancestor until it succeeds, stopping at any kind in stop_kinds or at the root. Read more
Source§

fn or_else_climb<O: Handler<Ctx, R>>( self, other: O, stop_kinds: &'static [&'static str], ) -> OrElseClimb<Self, O>

Try self on the original node; on None, try other on each ancestor. Read more
Source§

fn find_ancestor( self, target_kinds: &'static [&'static str], stop_kinds: &'static [&'static str], ) -> FindAncestor<Self>

Walk up to the nearest strict ancestor in target_kinds, then run self on that ancestor node once. Read more
Source§

fn for_children(self) -> ForChildren<Self>

Apply self to every named child, collect all Some(r) into a Vec<R>, and return Some(vec) (never None). Read more
Source§

fn scan_children(self) -> ScanChildren<Self>

Apply self to each named child in order; return the first Some(r), or None if no child matches. Read more
Source§

fn boxed(self) -> BoxedHandler<Ctx, R>
where Self: 'static, Ctx: Copy,

Erase the concrete type into a BoxedHandler for dynamic dispatch. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.