[][src]Struct cranelift_codegen_meta::srcgen::Formatter

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

Fields

indent: usizelines: Vec<String>

Methods

impl Formatter[src]

pub fn new() -> Self[src]

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

pub fn indent_push(&mut self)[src]

Increase current indentation level by one.

pub fn indent_pop(&mut self)[src]

Decrease indentation by one level.

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

fn get_indent(&self) -> String[src]

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

fn get_outdent(&mut self) -> String[src]

Get a string containing whitespace outdented one level. Used for lines of code that are inside a single indented block.

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

Add an indented line.

pub fn empty_line(&mut self)[src]

Pushes an empty line.

pub fn outdented_line(&mut self, s: &str)[src]

Emit a line outdented one level.

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

Write self.lines to a file.

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

Add one or more lines after stripping common indentation.

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

Add a comment line.

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

Add a (multi-line) documentation comment.

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

Add a match expression.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.