rust-format
A Rust source code formatting crate with a unified interface for string, file, and TokenStream input. It currently supports rustfmt and prettyplease.
It optionally supports post-processing replacement of special blank/comment markers for
inserting blank lines and comments in TokenStream generated source code
respectively (as used by quote-doctest
for inserting blanks/comments in generated doctests). It additionally supports
converting doc blocks (#[doc =""]) into doc comments (///).
NOTE: This is primarily to support rustfmt as prettyplease automatically
converts doc blocks into doc comments (but for rustfmt it requires nightly and
a configuration option).
Usage
[]
= "0.3"
Optional Features
post_process- enables support for post-process conversion of special "marker macros" into blank lines/comments. It additionally supports converting doc blocks (#[doc]) into doc comments (///)pretty_please- enables prettyplease formatting supporttoken_stream- enables formatting from TokenStream input
Examples
Simple example using default options of RustFmt:
use ;
Using a custom configuration:
use ;
RustFmt with post-processing:
use quote;
use ;
License
This project is licensed optionally under either:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)