pub struct PrettyPlease;
Expand description

This formatter uses prettyplease for formatting source code

From string:

use rust_format::{Formatter, PrettyPlease};

let source = r#"fn main() { println!("Hello World!"); }"#;

let actual = PrettyPlease.format_str(source).unwrap();
let expected = r#"fn main() {
    println!("Hello World!");
}
"#;

assert_eq!(expected, actual);

From token stream:

use quote::quote;
use rust_format::{Formatter, PrettyPlease};

let source = quote! { fn main() { println!("Hello World!"); } };

let actual = PrettyPlease.format_tokens(source).unwrap();
let expected = r#"fn main() {
    println!("Hello World!");
}
"#;

assert_eq!(expected, actual);

Trait Implementations

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 TokenStream and return the results in a 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

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 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.