Struct kotlin_poet_rs::spec::CodeBlock
source · pub struct CodeBlock { /* private fields */ }
Expand description
Plain list of nodes that can be rendered to a Kotlin code.
Implementations§
source§impl CodeBlock
impl CodeBlock
sourcepub fn atom(text: &str) -> CodeBlock
pub fn atom(text: &str) -> CodeBlock
Creates code block with a single atom node. Please avoid using it in [RenderKotlin::render], prefer CodeBlock::empty and CodeBlock::push_atom instead.
sourcepub fn statement(text: &str) -> CodeBlock
pub fn statement(text: &str) -> CodeBlock
Creates code block with a single atom node and empty line.
sourcepub fn push_statement(&mut self, text: &str)
pub fn push_statement(&mut self, text: &str)
Pushes [text] as atom and adds new line after it.
sourcepub fn push_renderable<T: RenderKotlin>(&mut self, renderable: &T)
pub fn push_renderable<T: RenderKotlin>(&mut self, renderable: &T)
Embeds all node from [code_block] into [self].
sourcepub fn push_indent(&mut self)
pub fn push_indent(&mut self)
Adds [CodeBlockNode::Indent] with value 1. In case there is already [CodeBlockNode::Indent] at the end of the list, increments its value.
sourcepub fn push_unindent(&mut self)
pub fn push_unindent(&mut self)
Adds [CodeBlockNode::Unindent] with value 1 In case there is already [CodeBlockNode::Unindent] at the end of the list, increments its value.
sourcepub fn push_new_line(&mut self)
pub fn push_new_line(&mut self)
Adds [CodeBlockNode::NewLine]
sourcepub fn push_space(&mut self)
pub fn push_space(&mut self)
Adds [CodeBlockNode::Space]
sourcepub fn push_curly_brackets<F>(&mut self, block: F)
pub fn push_curly_brackets<F>(&mut self, block: F)
Surrounds first parameter [block] with curly brackets + indent and adds it to [self].
sourcepub fn push_round_brackets<F>(&mut self, block: F)
pub fn push_round_brackets<F>(&mut self, block: F)
Surrounds first parameter [block] with round brackets and adds it to [self].
sourcepub fn push_angle_brackets<F>(&mut self, block: F)
pub fn push_angle_brackets<F>(&mut self, block: F)
Surrounds first parameter [block] with angle brackets and adds it to [self].
sourcepub fn push_comma_separated<F>(&mut self, elements: &[F])where
F: RenderKotlin,
pub fn push_comma_separated<F>(&mut self, elements: &[F])where
F: RenderKotlin,
Adds all elements from [elements] with comma separation, except for last one
Trait Implementations§
source§impl RenderKotlin for CodeBlock
impl RenderKotlin for CodeBlock
source§fn render_string(&self) -> String
fn render_string(&self) -> String
Auto Trait Implementations§
impl Freeze for CodeBlock
impl RefUnwindSafe for CodeBlock
impl Send for CodeBlock
impl Sync for CodeBlock
impl Unpin for CodeBlock
impl UnwindSafe for CodeBlock
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)