Skip to main content

Input

Struct Input 

Source
pub struct Input<'tree, Ctx> {
    pub node: Node<'tree>,
    pub ctx: Ctx,
    pub trigger_char: Option<char>,
}
Expand description

A snapshot of the current tree-sitter node together with caller-supplied context.

Input is designed to be passed by value; it is Copy whenever Ctx is Copy.

§Example

// Input<()> uses the unit type as a zero-sized context.
// In real usage Ctx is typically a shared reference to your extractor.
use tree_sitter_utils::Input;
fn accepts_input(_: Input<()>) {}

Fields§

§node: Node<'tree>

The current syntax-tree node being examined.

§ctx: Ctx

Caller-supplied context (e.g. a reference to an extractor struct).

§trigger_char: Option<char>

An optional trigger character hint (e.g. . or (), if the call site has one.

Implementations§

Source§

impl<'tree, Ctx> Input<'tree, Ctx>

Source

pub fn new(node: Node<'tree>, ctx: Ctx, trigger_char: Option<char>) -> Self

Construct a new Input.

§Example
use tree_sitter_utils::Input;
// Input::new(node, ctx, None)
Source

pub fn with_node(self, node: Node<'tree>) -> Self

Return a copy of this input with node replaced.

Useful inside combinators that need to walk the tree.

§Example
use tree_sitter_utils::Input;
// let parent_input = input.with_node(parent_node);

Trait Implementations§

Source§

impl<'tree, Ctx: Clone> Clone for Input<'tree, Ctx>

Source§

fn clone(&self) -> Input<'tree, Ctx>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'tree, Ctx: Copy> Copy for Input<'tree, Ctx>

Auto Trait Implementations§

§

impl<'tree, Ctx> Freeze for Input<'tree, Ctx>
where Ctx: Freeze,

§

impl<'tree, Ctx> RefUnwindSafe for Input<'tree, Ctx>
where Ctx: RefUnwindSafe,

§

impl<'tree, Ctx> Send for Input<'tree, Ctx>
where Ctx: Send,

§

impl<'tree, Ctx> Sync for Input<'tree, Ctx>
where Ctx: Sync,

§

impl<'tree, Ctx> Unpin for Input<'tree, Ctx>
where Ctx: Unpin,

§

impl<'tree, Ctx> UnsafeUnpin for Input<'tree, Ctx>
where Ctx: UnsafeUnpin,

§

impl<'tree, Ctx> UnwindSafe for Input<'tree, Ctx>
where Ctx: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.