Struct ToStringOptions

Source
pub struct ToStringOptions {
    pub pretty: bool,
    pub trailing_semicolon: bool,
    pub single_statement_on_new_line: bool,
    pub include_type_annotations: bool,
    pub include_decorators: bool,
    pub comments: Comments,
    pub indent_with: String,
    pub expect_jsx: bool,
    pub expect_markers: bool,
    pub max_line_length: u8,
}
Expand description

Settings for serializing ASTNodes

Fields§

§pretty: bool

Does not include whitespace minification

§trailing_semicolon: bool

Blocks have trailing semicolons. Has no effect if pretty == false

§single_statement_on_new_line: bool

Single statements get put on the same line as their parent statement

§include_type_annotations: bool

Include type annotations (and additional TypeScript) syntax

§include_decorators: bool

TODO unsure about this

§comments: Comments§indent_with: String§expect_jsx: bool

If false, panics if sees JSX

§expect_markers: bool

For partial AST, marker nodes may exist. This allows pretty printing on invalid source but should be false for builds

if false and a marker node is found, printing will panic

§max_line_length: u8

has no effect under !pretty

Implementations§

Source§

impl ToStringOptions

Source

pub fn minified() -> Self

Source

pub fn typescript() -> Self

With TypeScript type syntax

Trait Implementations§

Source§

impl Default for ToStringOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ToStringOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,