Trait rust_format::Formatter
source · [−]pub trait Formatter {
fn format_str(&self, source: impl AsRef<str>) -> Result<String, Error>;
fn format_file(&self, path: impl AsRef<Path>) -> Result<(), Error> { ... }
fn format_tokens(&self, tokens: TokenStream) -> Result<String, Error> { ... }
}
Expand description
A unified interface to all formatters. It allows for formatting from string, file, or TokenStream
Required methods
Provided methods
Format the given file specified hte path and overwrite the file with the results. An error is returned if any issues occur during formatting
fn format_tokens(&self, tokens: TokenStream) -> Result<String, Error>
fn format_tokens(&self, tokens: TokenStream) -> Result<String, Error>
This is supported on crate feature
token_stream
only.Format the given TokenStream and return the results in a String
.
An error is returned if any issues occur during formatting