[−][src]Struct cranelift_codegen_meta::srcgen::Formatter
Fields
indent: usize
lines: Vec<String>
Implementations
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]
&self,
filename: impl AsRef<str>,
directory: &str
) -> Result<(), Error>
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
impl RefUnwindSafe for Formatter
impl Send for Formatter
impl Sync for Formatter
impl Unpin for Formatter
impl UnwindSafe for Formatter
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,