Refactor libimagtodo to fit new store iterator interface

This commit is contained in:
Matthias Beyer 2018-04-30 17:28:54 +02:00
parent 72c83ae3f7
commit 715753ed25

View file

@ -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
} }
} }