sigil-stitch
A Rust library for type-safe, multi-language code generation that tracks imports, resolves naming conflicts, and produces width-aware formatted output.
sigil-stitch generates source code for multiple target languages from Rust. It combines a JavaPoet-style builder and CodeBlock model with Wadler-Lindig pretty printing, so generated code is automatically formatted and import-aware: type references written with the %T specifier are tracked automatically, and naming conflicts are resolved for you.
The library offers two ways to build code: a programmatic builder API for dynamic generation, and a sigil_quote! macro for writing target-language code inline with $T/$S/$N/$L/$C/$V/$W interpolation markers. The macro also supports structural annotations, type-name joins, splicing of code blocks, meta-conditionals, compile-time iteration, and language-aware handling of paren-delimited blocks such as Go's const(), var(), and import().
It targets Rust edition 2024 and MSRV 1.88.0, and depends on pretty for formatting, serde for JSON/YAML round-tripping of specs, and snafu for structured errors.