mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-29 20:44:25 +00:00
return position as the option
This commit is contained in:
parent
6203ef5b28
commit
467a287468
@ -95,7 +95,7 @@ impl Navigation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> usize {
|
pub fn position(&self) -> Option<usize> {
|
||||||
self.model.borrow().position()
|
self.model.borrow().position()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ impl<T> Model<T> {
|
|||||||
self.vector.get(self.cursor.as_index())
|
self.vector.get(self.cursor.as_index())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> usize {
|
pub fn position(&self) -> Option<usize> {
|
||||||
self.cursor.as_position()
|
self.cursor.as_position()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,11 @@ impl Cursor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_position(&self) -> usize {
|
pub fn as_position(&self) -> Option<usize> {
|
||||||
self.current
|
if self.current > 0 {
|
||||||
|
Some(self.current)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ impl Result {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
pub fn update(&self, current: usize, total: usize) {
|
pub fn update(&self, current: Option<usize>, total: usize) {
|
||||||
if total > 0 {
|
if total > 0 {
|
||||||
if current > 0 {
|
match current {
|
||||||
self.label
|
Some(position) => self
|
||||||
.set_label(&format!("{current} of {total} matches"));
|
.label
|
||||||
} else {
|
.set_label(&format!("{position} of {total} matches")),
|
||||||
self.label.set_label(&format!("{total} matches"));
|
None => self.label.set_label(&format!("{total} matches")),
|
||||||
}
|
}
|
||||||
self.label.remove_css_class("error");
|
self.label.remove_css_class("error");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user