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:
EdJoPaTo
2024-05-01 01:45:54 +02:00
parent 701be9315d
commit fdd2c5436a
5 changed files with 88 additions and 88 deletions
+28
View File
@@ -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() {