Struct rust_format::PrettyPlease
source · [−]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
sourceimpl PrettyPlease
impl PrettyPlease
Trait Implementations
sourceimpl Default for PrettyPlease
impl Default for PrettyPlease
sourcefn default() -> PrettyPlease
fn default() -> PrettyPlease
Returns the “default value” for a type. Read more
sourceimpl Formatter for PrettyPlease
impl Formatter for PrettyPlease
sourcefn format_str(&self, source: impl AsRef<str>) -> Result<String, Error>
fn format_str(&self, source: impl AsRef<str>) -> Result<String, Error>
Format the given string and return the results in another String. An error is returned
if any issues occur during formatting Read more
sourcefn 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 Read more
Auto Trait Implementations
impl RefUnwindSafe for PrettyPlease
impl Send for PrettyPlease
impl Sync for PrettyPlease
impl Unpin for PrettyPlease
impl UnwindSafe for PrettyPlease
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more