Macro shrimple_parser::call
source · macro_rules! call { ($($args:tt)*) => { ... }; }
Expand description
Generates a closure that calls a function with a tuple’s contents as it arguments. The input can be anything as long as the last token contains all the arguments parenthesized.
use shrimple_parser::{Parser, parse_until_exact, call};
fn len_sum(a: &str, b: &str) -> usize {
a.len() + b.len()
}
let input = "abc|def|";
let res = parse_until_exact("|")
.and(parse_until_exact("|"))
.map(call!(len_sum(a, b)))
(input);
assert_eq!(res, Ok(("", 6)))