pub struct CodeBuffer { /* private fields */ }Expand description
A CodeBuffer is a buffer that can be used to generate code without having
to keep track of identation. A CodeBuffer contains either plain text which
will be indented accoridng to the buffer’s own indent, or nested
CodeBuffers which will be intended according to their own indent, on top
of the containing buffer’s indent.
Implementations§
Source§impl CodeBuffer
impl CodeBuffer
Sourcepub fn line(&self, text: impl Into<Cow<'static, str>>)
pub fn line(&self, text: impl Into<Cow<'static, str>>)
Adds text into the buffer, followed by a new line.
Sourcepub fn indent(&self, indent: Cow<'static, str>) -> Rc<CodeBuffer>
pub fn indent(&self, indent: Cow<'static, str>) -> Rc<CodeBuffer>
Creates a new indented sub-buffer at the current position.
Sourcepub fn indent_with_options(&self, options: IndentOptions) -> Rc<CodeBuffer>
pub fn indent_with_options(&self, options: IndentOptions) -> Rc<CodeBuffer>
Creates a new indented sub-buffer at the current position.
Sourcepub fn section(&self, trailing_newline: bool) -> Rc<CodeBuffer>
pub fn section(&self, trailing_newline: bool) -> Rc<CodeBuffer>
Creates a new un-indented sub-buffer at the current position.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CodeBuffer
impl !RefUnwindSafe for CodeBuffer
impl !Send for CodeBuffer
impl !Sync for CodeBuffer
impl !UnwindSafe for CodeBuffer
impl Unpin for CodeBuffer
impl UnsafeUnpin for CodeBuffer
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