This commit is contained in:
Hanno Braun 2024-12-11 21:14:11 +01:00
parent c0c5a281fd
commit f5d315dbaf
2 changed files with 9 additions and 12 deletions

View File

@ -78,7 +78,7 @@ impl TextRenderer {
}, },
); );
for (op, selected, indent) in operations.operations().into_iter() { for (op, selected, indent) in operations.operations() {
let mut attrs = glyphon::Attrs::new(); let mut attrs = glyphon::Attrs::new();
if selected { if selected {

View File

@ -24,15 +24,13 @@ impl OperationView {
} }
} }
pub fn operations(&self) -> Vec<(&Self, bool, usize)> { pub fn operations(&self) -> impl Iterator<Item = (&Self, bool, usize)> {
iter::once((self, true, 0)) iter::once((self, true, 0)).chain(
.chain(
self.children self.children
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, op)| (op, Some(i) == self.selected, 1)), .map(|(i, op)| (op, Some(i) == self.selected, 1)),
) )
.collect()
} }
pub fn select_last(&mut self) { pub fn select_last(&mut self) {
@ -55,7 +53,6 @@ impl OperationView {
self.selected self.selected
.and_then(|selected| { .and_then(|selected| {
self.operations() self.operations()
.into_iter()
.nth(selected) .nth(selected)
.map(|(op, _, _)| op) .map(|(op, _, _)| op)
.cloned() .cloned()
@ -64,7 +61,7 @@ impl OperationView {
} }
fn last_index(&self) -> usize { fn last_index(&self) -> usize {
self.operations().len().saturating_sub(1) self.operations().count().saturating_sub(1)
} }
} }