pub struct Block {
pub connect: bool,
pub start: String,
pub end: String,
/* private fields */
}Expand description
A block of code with a starting line, ending line, and an indented body
Fields§
§connect: boolIf this block should be connected to the end of a previous block
(for example, else {)
start: StringThe start of the block (for example, if (x) {)
end: StringThe end of the block (for example, })
Implementations§
Source§impl Block
impl Block
Sourcepub fn empty<TStart, TEnd>(start: TStart, end: TEnd) -> Self
pub fn empty<TStart, TEnd>(start: TStart, end: TEnd) -> Self
Create a new block with empty body
Sourcepub fn new<TStart, TBody, TEnd>(start: TStart, body: TBody, end: TEnd) -> Self
pub fn new<TStart, TBody, TEnd>(start: TStart, body: TBody, end: TEnd) -> Self
Create a new code block
Sourcepub fn connected(self) -> Self
pub fn connected(self) -> Self
Set this block to start on the same line as the end of the previous block
Sourcepub fn inline_when(self, condition: fn(&Block) -> bool) -> Self
pub fn inline_when(self, condition: fn(&Block) -> bool) -> Self
Set a condition for displaying the block as one line
Sourcepub fn never_inlined(self) -> Self
pub fn never_inlined(self) -> Self
Set the inline condition to be always false
Sourcepub fn should_inline(&self) -> bool
pub fn should_inline(&self) -> bool
Should the block be displayed in one line
Sourcepub fn should_inline_intrinsic(&self) -> bool
pub fn should_inline_intrinsic(&self) -> bool
Should intrinsicly inline the block
This is used for blocks that only contain one line of code
Trait Implementations§
Source§impl FormatCode for Block
impl FormatCode for Block
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
Upperbound for the line count of the code for pre-allocating. Return 0 to skip
Source§fn format_into_vec_with(
&self,
format: &Format,
out: &mut Vec<String>,
connect: bool,
indent: &str,
)
fn format_into_vec_with( &self, format: &Format, out: &mut Vec<String>, connect: bool, indent: &str, )
Emit self with the format in the given output context
Source§fn format_with(&self, format: &Format) -> String
fn format_with(&self, format: &Format) -> String
Emit self with the format as a string
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
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