mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-28 03:54:15 +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()
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl<T> Model<T> {
|
||||
self.vector.get(self.cursor.as_index())
|
||||
}
|
||||
|
||||
pub fn position(&self) -> usize {
|
||||
pub fn position(&self) -> Option<usize> {
|
||||
self.cursor.as_position()
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,11 @@ impl Cursor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_position(&self) -> usize {
|
||||
self.current
|
||||
pub fn as_position(&self) -> Option<usize> {
|
||||
if self.current > 0 {
|
||||
Some(self.current)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ impl Result {
|
||||
|
||||
// Actions
|
||||
|
||||
pub fn update(&self, current: usize, total: usize) {
|
||||
pub fn update(&self, current: Option<usize>, total: usize) {
|
||||
if total > 0 {
|
||||
if current > 0 {
|
||||
self.label
|
||||
.set_label(&format!("{current} of {total} matches"));
|
||||
} else {
|
||||
self.label.set_label(&format!("{total} matches"));
|
||||
match current {
|
||||
Some(position) => self
|
||||
.label
|
||||
.set_label(&format!("{position} of {total} matches")),
|
||||
None => self.label.set_label(&format!("{total} matches")),
|
||||
}
|
||||
self.label.remove_css_class("error");
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user