pub struct PrettyPlease { /* private fields */ }
This is supported on crate feature pretty_please only.
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::default().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::default().format_tokens(source).unwrap();
let expected = r#"fn main() {
    println!("Hello World!");
}
"#;

assert_eq!(expected, actual);

Implementations

Creates a new instance of PrettyPlease using a default configuration

Creates a new instance of PrettyPlease 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

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

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