Using rustfmt as a library?

I'm trying to debug a proc-macro, and am wondering if there is a nice way to use rustfmt as a library? It's got very sparse documentation. I'm just looking for a way to format my proc_macro2::TokenStream such that I can effectively read it as rust code. Any other way to pretty print rust code would also work, if anyone has a suggestion.

In rust-analyzer, we just shell out to the rustfmt binary for similar purposes: rust-analyzer/codegen.rs at ada9e16537c22b490d13cdd54b9e1e4885856a4c · rust-lang/rust-analyzer · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.