Skip to main content

handler_fn

Function handler_fn 

Source
pub fn handler_fn<Ctx, R, F>(f: F) -> HandlerFn<F>
where F: Fn(Input<'_, Ctx>) -> R + Send + Sync,
Expand description

Wrap an infallible function as a Handler that always returns Some.

Use this when your mapping function cannot fail.

ยงExample

use tree_sitter_utils::{handler_fn, Handler, Input};

let h = handler_fn(|input: Input<()>| input.node.kind().to_owned());
let _ = h;