Sorry if anyone has asked about this. I mean, is there a way to make a crate like macro crate make custom proc macro to be formatted by rustfmt?
If you are wanting to turn a proc_macro::TokenStream
into formatted source code (e.g. so you can generate code and save it to a file), you can always use std::process::Command
to invoke rustfmt
and pass it your token_stream.to_string()
as stdin.
Otherwise, the prettyplease
crate is nice when you want "good enough" formatting to make your generated code readable.
I'm sorry I misunderstood before. What I want is to format custom syntax inside macro braces, like
custom_lambda! {
x => {
10
}
}
prettyplease
seems unable to format complex custom syntax.
I wonder if there is a way I could "guide" rustfmt to format my custom syntax?
Not as far as I know.
Thanks
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.