dtolnay / quote

Rust quasi-quoting
Apache License 2.0
1.32k stars 90 forks source link

How to pass the result of `quote!` to prettyplease? #258

Closed sztomi closed 1 year ago

sztomi commented 1 year ago

The documentation says

When using quote in a build.rs or main.rs and writing the output out to a file, consider having the code generator pass the tokens through [prettyplease](https://github.com/dtolnay/prettyplease) before writing.

but how? The result of quote! is a TokenStream, but prettyplease expects a syn::File. Is there a straightforward & efficient conversion?

dtolnay commented 1 year ago

https://docs.rs/syn/2/syn/fn.parse_file.html

dtolnay commented 1 year ago

Er, this one: https://docs.rs/syn/2/syn/fn.parse2.html

sztomi commented 1 year ago

Thanks!