Macro unrest_tmp_synom::map
[−]
[src]
macro_rules! map { ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => { ... }; ($i:expr, $f:expr, $g:expr) => { ... }; }
Transform the result of a parser by applying a function or closure.
- Syntax:
map!(THING, FN)
- Output: the return type of function FN applied to THING
extern crate syn; #[macro_use] extern crate synom; use syn::{Expr, ExprIf}; fn get_cond(if_: ExprIf) -> Expr { *if_.cond } // Parses an `if` statement but returns the condition part only. named!(if_condition -> Expr, map!(syn!(ExprIf), get_cond) ); // Or equivalently: named!(if_condition2 -> Expr, map!(syn!(ExprIf), |if_| *if_.cond) );