mirror of
https://github.com/hannobraun/Fornjot
synced 2025-07-07 18:46:06 +00:00
Simplify
This commit is contained in:
parent
c0c5a281fd
commit
f5d315dbaf
@ -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 {
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user