pub struct Codize {
pub indent: usize,
pub inline_condition: Box<dyn Fn(&Block) -> bool>,
pub trailing_newline: bool,
}Expand description
Codize formatter
This turns a Code into a string, joined with newlines.
There are formatting options you can set through its methods or by directly constructing it.
Fields§
§indent: usizeThe number of spaces to indent per level.
inline_condition: Box<dyn Fn(&Block) -> bool>A function that determines whether a block should be inlined.
When the block is inlined, the body is put on the same line as the start and the end, and the body will be separated by a space instead of a newline. For example, you can set the block to inline if it only contains one line of code.
Note that this function is called on blocks of all levels. You can use the block starting and ending strings to do basic filtering
trailing_newline: boolIf a trailing newline should be added when there is none
Implementations§
source§impl Codize
impl Codize
sourcepub fn set_indent(self, indent: usize) -> Self
pub fn set_indent(self, indent: usize) -> Self
Set indent
sourcepub fn always_inline() -> Self
pub fn always_inline() -> Self
Set the blocks to always inline
sourcepub fn set_always_inline(self) -> Self
pub fn set_always_inline(self) -> Self
Set the blocks to always inline
sourcepub fn inline_when<F>(condition: F) -> Self
pub fn inline_when<F>(condition: F) -> Self
Set the inline condition
sourcepub fn set_inline_when<F>(self, condition: F) -> Self
pub fn set_inline_when<F>(self, condition: F) -> Self
Set the inline condition
sourcepub fn trailing_newline(trailing_newline: bool) -> Self
pub fn trailing_newline(trailing_newline: bool) -> Self
Set if there should be trailing newline
sourcepub fn set_trailing_newline(self, trailing_newline: bool) -> Self
pub fn set_trailing_newline(self, trailing_newline: bool) -> Self
Set if there should be trailing newline