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 Clone for PrettyPlease
impl Clone for PrettyPlease
sourcefn clone(&self) -> PrettyPlease
fn clone(&self) -> PrettyPlease
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more