Struct cranelift_codegen_meta::srcgen::Formatter
source · pub(crate) struct Formatter {
indent: usize,
lines: Vec<String>,
}
Fields§
§indent: usize
§lines: Vec<String>
Implementations§
source§impl Formatter
impl Formatter
sourcepub fn new() -> Self
pub fn new() -> Self
Source code formatter class. Used to collect source code to be written to a file, and keep track of indentation.
sourcepub fn indent_push(&mut self)
pub fn indent_push(&mut self)
Increase current indentation level by one.
sourcepub fn indent_pop(&mut self)
pub fn indent_pop(&mut self)
Decrease indentation by one level.
pub fn indent<T, F: FnOnce(&mut Formatter) -> T>(&mut self, f: F) -> T
sourcefn get_indent(&self) -> String
fn get_indent(&self) -> String
Get the current whitespace indentation in the form of a String.
sourcepub fn empty_line(&mut self)
pub fn empty_line(&mut self)
Pushes an empty line.
sourcepub fn update_file(
&self,
filename: impl AsRef<str>,
directory: &str
) -> Result<(), Error>
pub fn update_file( &self, filename: impl AsRef<str>, directory: &str ) -> Result<(), Error>
Write self.lines
to a file.
sourcepub fn multi_line(&mut self, s: &str)
pub fn multi_line(&mut self, s: &str)
Add one or more lines after stripping common indentation.
sourcepub fn doc_comment(&mut self, contents: impl AsRef<str>)
pub fn doc_comment(&mut self, contents: impl AsRef<str>)
Add a (multi-line) documentation comment.
Auto Trait Implementations§
impl Freeze for Formatter
impl RefUnwindSafe for Formatter
impl Send for Formatter
impl Sync for Formatter
impl Unpin for Formatter
impl UnwindSafe for Formatter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more