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<Path>,
directory: &Path,
) -> Result<(), Error>
pub fn update_file( &self, filename: impl AsRef<Path>, directory: &Path, ) -> 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