Skip to main content

CodegenOptions

Struct CodegenOptions 

Source
pub struct CodegenOptions {
    pub single_quote: bool,
    pub minify: bool,
    pub ascii_only: bool,
    pub comments: CommentOptions,
    pub source_map_path: Option<PathBuf>,
    pub indent_char: IndentChar,
    pub indent_width: usize,
    pub initial_indent: u32,
}
Expand description

Codegen Options.

Fields§

§single_quote: bool

Use single quotes instead of double quotes.

Default is false.

§minify: bool

Remove whitespace.

Default is false.

§ascii_only: bool

Escape non-ASCII characters in string literals, untagged template literals, regular expression literals and identifier names.

Uses \uXXXX for characters up to U+FFFF and \u{...} for higher code points. Regular expressions use escaped UTF-16 surrogate pairs for higher code points instead; escaping changes the observable RegExp.prototype.source value.

Code point escapes (\u{...}) require ES2015 or later; this option does not provide ES5-compatible output.

Non-ASCII characters are left unescaped in tagged template quasis (whose raw text is observable), JSX names and text, JSX attribute strings, hashbangs and preserved comments. JavaScript expressions inside tagged templates and JSX are escaped normally.

Default is false.

§comments: CommentOptions

Print comments?

At present, only some leading comments are preserved.

Default is CommentOptions::default.

§source_map_path: Option<PathBuf>

Enable sourcemap.

The provided path sets the source field in the returned sourcemap.

Default is None - no sourcemap is produced.

§indent_char: IndentChar

Indentation character.

Default is IndentChar::Tab.

§indent_width: usize

Number of characters per indentation level.

Default is 1.

§initial_indent: u32

Initial indentation level for generated code.

Default is 0.

Implementations§

Source§

impl CodegenOptions

Source

pub fn minify() -> Self

Minify whitespace and remove comments.

Trait Implementations§

Source§

impl Clone for CodegenOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodegenOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CodegenOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.