Skip to main content

Always

Struct Always 

Source
pub struct Always<R>(pub R);
Expand description

Handler produced by always.

§Example

use tree_sitter_utils::always;
let h = always::<(), u32>(42);
let _ = h;

Tuple Fields§

§0: R

Implementations§

Source§

impl<R> Always<R>

Source

pub const fn new_const(value: R) -> Self

Construct an Always handler in a const / static context.

§Example
use tree_sitter_utils::constructors::Always;
static H: Always<u32> = Always::new_const(42u32);

Trait Implementations§

Source§

impl<Ctx, R: Clone + Send + Sync> Handler<Ctx, R> for Always<R>

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<R> Freeze for Always<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Always<R>
where R: RefUnwindSafe,

§

impl<R> Send for Always<R>
where R: Send,

§

impl<R> Sync for Always<R>
where R: Sync,

§

impl<R> Unpin for Always<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for Always<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for Always<R>
where R: UnwindSafe,

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.