MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / set_items

Method set_items

crates/hyperqueue/src/dashboard/ui/widgets/table.rs:41–52  ·  view source on GitHub ↗

Sets new items for the table. Invariant: if there are no items in the table, no item is selected.

(&mut self, items: Vec<T>)

Source from the content-addressed store, hash-verified

39 ///
40 /// Invariant: if there are no items in the table, no item is selected.
41 pub fn set_items(&mut self, items: Vec<T>) {
42 self.items = items;
43
44 // Make sure that our selection does not dangle
45 if !self.has_items() {
46 self.state.select(None);
47 } else if let Some(index) = self.state.selected()
48 && index >= self.items.len()
49 {
50 self.select_last();
51 }
52 }
53
54 pub fn current_selection(&self) -> Option<&T> {
55 if let Some(selection_index) = self.state.selected() {

Callers 8

updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80

Calls 3

has_itemsMethod · 0.80
select_lastMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected