Syn builder

Builder functions for syn structures and enums to ease the generation of Rust code.

Note: only syn structures are creating using the builder methods - there no intermediate structs to manage.

Usage

  1. Add to your Cargo.toml file toml [dependencies] syn_builder = "0.2.0"

  2. Import builder functions and create syn objects ```rust use procmacro2::TokenStream; use quote::ToTokens; use synbuilder::*;

fn main() { //generate code using the builder api let code = itemenum("myenum").variants([ variant("A").fields( fieldsunamed([field(typepath("A")), field(typepath("B"))]), ), variant("B"), variant("C").fields( fieldsnamed([ field(typepath("A")).ident("other"), field(typepath("B")).ident("one"), ]), ), ]);

let mut token_stream = TokenStream::new();
code.to_tokens(&mut token_stream);

println!("{token_stream}");

} ```

Alternatives