Trait syn::synom::ext::IdentExt [] [src]

pub trait IdentExt: Sized + Sealed {
    fn parse_any(input: Cursor) -> PResult<Self>;
}

Additional parsing methods for Ident.

This trait is sealed and cannot be implemented for types outside of Syn.

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

Required Methods

Parses any identifier including keywords.

This is useful when parsing a DSL which allows Rust keywords as identifiers.

#[macro_use]
extern crate syn;

use syn::Ident;

// Parses input that looks like `name = NAME` where `NAME` can be
// any identifier.
//
// Examples:
//
//     name = anything
//     name = impl
named!(parse_dsl -> Ident, do_parse!(
    custom_keyword!(name) >>
    punct!(=) >>
    name: call!(Ident::parse_any) >>
    (name)
));

Implementors