pub struct RustFmt { /* private fields */ }
Expand description

This formatter uses rustfmt for formatting source code

An example using a custom configuration:

use rust_format::{Config, Edition, Formatter, RustFmt};

let source = r#"use std::marker; use std::io; mod test; mod impls;"#;

let mut config = Config::new_str()
    .edition(Edition::Rust2018)
    .option("reorder_imports", "false")
    .option("reorder_modules", "false");
let rustfmt = RustFmt::from_config(config);

let actual = rustfmt.format_str(source).unwrap();
let expected = r#"use std::marker;
use std::io;
mod test;
mod impls;
"#;

assert_eq!(expected, actual);

Implementations

Creates a new instance of RustFmt using a default configuration

Creates a new instance of the formatter from the given configuration

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Format the given string and return the results in another String. An error is returned if any issues occur during formatting Read more

Format the given file specified hte path and overwrite the file with the results. An error is returned if any issues occur during formatting Read more

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 Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.