Function new_string_data

Source
pub fn new_string_data(data: &[&str]) -> NodeChildren
Expand description

Creates a NodeChildren collection from string slice data.

This is a convenience function for quickly creating a collection of leaf nodes from string data. Each string becomes a visible leaf node.

§Arguments

  • data - A slice of string references to convert into leaf nodes

§Returns

A NodeChildren collection containing a leaf node for each string

§Examples

use lipgloss_tree::{new_string_data, Children, Node};

let children = new_string_data(&["Item 1", "Item 2", "Item 3"]);
assert_eq!(children.length(), 3);
assert_eq!(children.at(0).unwrap().value(), "Item 1");