pub(crate) struct Formatter {
    indent: usize,
    lines: Vec<String>,
}

Fields§

§indent: usize§lines: Vec<String>

Implementations§

source§

impl Formatter

source

pub fn new() -> Self

Source code formatter class. Used to collect source code to be written to a file, and keep track of indentation.

source

pub fn indent_push(&mut self)

Increase current indentation level by one.

source

pub fn indent_pop(&mut self)

Decrease indentation by one level.

source

pub fn indent<T, F: FnOnce(&mut Formatter) -> T>(&mut self, f: F) -> T

source

fn get_indent(&self) -> String

Get the current whitespace indentation in the form of a String.

source

pub fn line(&mut self, contents: impl AsRef<str>)

Add an indented line.

source

pub fn empty_line(&mut self)

Pushes an empty line.

source

pub fn update_file( &self, filename: impl AsRef<str>, directory: &str ) -> Result<(), Error>

Write self.lines to a file.

source

pub fn multi_line(&mut self, s: &str)

Add one or more lines after stripping common indentation.

source

pub fn comment(&mut self, s: impl AsRef<str>)

Add a comment line.

source

pub fn doc_comment(&mut self, contents: impl AsRef<str>)

Add a (multi-line) documentation comment.

source

pub fn add_match(&mut self, m: Match)

Add a match expression.

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>,

§

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>,

§

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.