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();
if selected {

View File

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