pub type Indenter = fn(&dyn Children, usize) -> String;
Expand description
Function type for generating indentation strings for nested tree content.
An Indenter
generates the indentation used for child nodes that appear
below their parent. This creates the visual connection lines between
parent and nested content. The indentation typically differs based on
whether there are more siblings following (│ continues the line) or if
this is the last child (spaces for clean termination).
§Arguments
children
- The children collection being indentedindex
- The zero-based index of the current child
§Returns
A string representing the indentation for nested content under this child
§Examples
use lipgloss_tree::{Children, Indenter};
let custom_indenter: Indenter = |children, index| {
if index == children.length() - 1 {
" ".to_string() // Spaces for last child
} else {
"│ ".to_string() // Vertical line for continuing branches
}
};