Skip to main content

Crate tanager

Crate tanager 

Source
Expand description

Parse Rust literal struct expressions using syn.

tanager is intended for proc-macro authors who want to accept syntax that resembles ordinary Rust struct expressions.

The crate provides a Parse trait and a derive macro for implementing it. Parsed values are constructed directly from Rust literals and nested structures rather than from custom attribute syntax.

§Example

use tanager::Parse;

#[derive(Parse)]
struct Config {
    name: String,
    enabled: bool,
}

// Parses:
// {
//     name: "example",
//     enabled: true,
// }

Most users will derive Parse and then use parse to parse a proc_macro2::TokenStream.

The derive macro is available with the macros feature enabled.

Traits§

Parse
Parses a value from a Rust literal expression.

Functions§

parse
Parses a value from a token stream.
parse_without_container
Parses a value from a token stream without requiring its outer container.

Type Aliases§

ParseStream
Result type used throughout tanager parsing APIs. Input to a Syn parser function.
Result
Result type used throughout tanager parsing APIs. The result of a Syn parser.

Derive Macros§

Parse
Derive Parse for a struct or enum.