Macro syn::syn [] [src]

macro_rules! syn {
    ($i:expr, $t:ty) => { ... };
}

Parse any type that implements the Synom trait.

Any type implementing Synom can be used with this parser, whether the implementation is provided by Syn or is one that you write.

#[macro_use]
extern crate syn;

use syn::{Ident, Item};
use syn::token::Brace;
use syn::synom::Synom;

/// Parses a module containing zero or more Rust items.
///
/// Example: `mod m { type Result<T> = ::std::result::Result<T, MyError>; }`
struct SimpleMod {
    mod_token: Token![mod],
    name: Ident,
    brace_token: Brace,
    items: Vec<Item>,
}

impl Synom for SimpleMod {
    named!(parse -> Self, do_parse!(
        mod_token: keyword!(mod) >>
        name: syn!(Ident) >>
        body: braces!(many0!(syn!(Item))) >>
        (SimpleMod {
            mod_token,
            name,
            brace_token: body.0,
            items: body.1,
        })
    ));
}

This macro is available if Syn is built with the "parsing" feature.