pub struct PrettyPlease { /* private fields */ }
Available 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§
Source§impl PrettyPlease
impl PrettyPlease
Trait Implementations§
Source§impl Clone for PrettyPlease
impl Clone for PrettyPlease
Source§fn clone(&self) -> PrettyPlease
fn clone(&self) -> PrettyPlease
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for PrettyPlease
impl Default for PrettyPlease
Source§fn default() -> PrettyPlease
fn default() -> PrettyPlease
Returns the “default value” for a type. Read more
Source§impl Formatter for PrettyPlease
impl Formatter for PrettyPlease
Source§fn 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 formattingSource§fn format_tokens(&self, tokens: TokenStream) -> Result<String, Error>
fn format_tokens(&self, tokens: TokenStream) -> Result<String, Error>
Available 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 formattingAuto Trait Implementations§
impl Freeze for PrettyPlease
impl RefUnwindSafe for PrettyPlease
impl Send for PrettyPlease
impl Sync for PrettyPlease
impl Unpin for PrettyPlease
impl UnwindSafe for PrettyPlease
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more