Refactor libimagtodo to fit new store iterator interface
This commit is contained in:
parent
72c83ae3f7
commit
715753ed25
1 changed files with 7 additions and 3 deletions
|
@ -20,6 +20,9 @@
|
||||||
use libimagstore::storeid::StoreIdIterator;
|
use libimagstore::storeid::StoreIdIterator;
|
||||||
use libimagstore::storeid::StoreId;
|
use libimagstore::storeid::StoreId;
|
||||||
|
|
||||||
|
use error::Result;
|
||||||
|
use error::TodoError as TE;
|
||||||
|
|
||||||
pub struct TaskIdIterator(StoreIdIterator);
|
pub struct TaskIdIterator(StoreIdIterator);
|
||||||
|
|
||||||
impl TaskIdIterator {
|
impl TaskIdIterator {
|
||||||
|
@ -31,14 +34,15 @@ impl TaskIdIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for TaskIdIterator {
|
impl Iterator for TaskIdIterator {
|
||||||
type Item = StoreId;
|
type Item = Result<StoreId>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
loop {
|
loop {
|
||||||
match self.0.next() {
|
match self.0.next() {
|
||||||
None => return None,
|
None => return None,
|
||||||
Some(n) => if n.is_in_collection(&["todo", "taskwarrior"]) {
|
Some(Err(e)) => return Some(Err(e).map_err(TE::from)),
|
||||||
return Some(n)
|
Some(Ok(n)) => if n.is_in_collection(&["todo", "taskwarrior"]) {
|
||||||
|
return Some(Ok(n))
|
||||||
}, // else continue
|
}, // else continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue