[][src]Trait syn::synom::Synom

pub trait Synom: Sized {
    fn parse(input: Cursor) -> PResult<Self>;

    fn description() -> Option<&'static str> { ... }
}

Parsing interface implemented by all types that can be parsed in a default way from a token stream.

Refer to the module documentation for details about parsing in Syn.

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

Required Methods

Provided Methods

A short name of the type being parsed.

The description should only be used for a simple name. It should not contain newlines or sentence-ending punctuation, to facilitate embedding in larger user-facing strings. Syn will use this description when building error messages about parse failures.

Examples

struct ExprMacro {
    // ...
}

impl Synom for ExprMacro {
    // fn parse(...) -> ... { ... }

    fn description() -> Option<&'static str> {
        // Will result in messages like
        //
        //     "failed to parse macro invocation expression: $reason"
        Some("macro invocation expression")
    }
}

Implementations on Foreign Types

impl Synom for TokenStream
[src]

impl Synom for TokenTree
[src]

impl Synom for Group
[src]

impl Synom for Punct
[src]

impl Synom for Literal
[src]

Implementors