feat!: cache last tree structure to simplify events
Things like key up/down dont require the items anymore to be used. Instead a cached last state from last render is used.
This commit is contained in:
@@ -141,6 +141,34 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeItem<'static, &'static str> {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn example() -> Vec<Self> {
|
||||
vec![
|
||||
TreeItem::new_leaf("a", "Alfa"),
|
||||
TreeItem::new(
|
||||
"b",
|
||||
"Bravo",
|
||||
vec![
|
||||
TreeItem::new_leaf("c", "Charlie"),
|
||||
TreeItem::new(
|
||||
"d",
|
||||
"Delta",
|
||||
vec![
|
||||
TreeItem::new_leaf("e", "Echo"),
|
||||
TreeItem::new_leaf("f", "Foxtrot"),
|
||||
],
|
||||
)
|
||||
.expect("all item identifiers are unique"),
|
||||
TreeItem::new_leaf("g", "Golf"),
|
||||
],
|
||||
)
|
||||
.expect("all item identifiers are unique"),
|
||||
TreeItem::new_leaf("h", "Hotel"),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic = "duplicate identifiers"]
|
||||
fn tree_item_new_errors_with_duplicate_identifiers() {
|
||||
|
||||
Reference in New Issue
Block a user