Make filter iterators generic for all iterators
This commit is contained in:
parent
049d853cba
commit
797ce777b7
1 changed files with 25 additions and 12 deletions
|
@ -20,6 +20,7 @@
|
||||||
use error::TimeTrackError as TTE;
|
use error::TimeTrackError as TTE;
|
||||||
use error::TimeTrackErrorKind as TTEK;
|
use error::TimeTrackErrorKind as TTEK;
|
||||||
use error::MapErrInto;
|
use error::MapErrInto;
|
||||||
|
use result::Result;
|
||||||
|
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagstore::store::FileLockEntry;
|
||||||
use libimagstore::store::Store;
|
use libimagstore::store::Store;
|
||||||
|
@ -30,14 +31,18 @@ use iter::get::GetTimeTrackIter;
|
||||||
use tag::TimeTrackingTag as TTT;
|
use tag::TimeTrackingTag as TTT;
|
||||||
use timetracking::TimeTracking;
|
use timetracking::TimeTracking;
|
||||||
|
|
||||||
pub struct WithOneOf<'a> {
|
pub struct WithOneOf<'a, I>
|
||||||
iter: GetTimeTrackIter<'a>,
|
where I: Iterator<Item = Result<FileLockEntry<'a>>>
|
||||||
|
{
|
||||||
|
iter: I,
|
||||||
allowed_tags: &'a Vec<TTT>,
|
allowed_tags: &'a Vec<TTT>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WithOneOf<'a> {
|
impl<'a, I> WithOneOf<'a, I>
|
||||||
|
where I: Iterator<Item = Result<FileLockEntry<'a>>>
|
||||||
|
{
|
||||||
|
|
||||||
pub fn new(iter: GetTimeTrackIter<'a>, allowed_tags: &'a Vec<TTT>) -> WithOneOf<'a> {
|
pub fn new(iter: I, allowed_tags: &'a Vec<TTT>) -> WithOneOf<'a, I> {
|
||||||
WithOneOf {
|
WithOneOf {
|
||||||
iter: iter,
|
iter: iter,
|
||||||
allowed_tags: allowed_tags
|
allowed_tags: allowed_tags
|
||||||
|
@ -45,8 +50,10 @@ impl<'a> WithOneOf<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for WithOneOf<'a> {
|
impl<'a, I> Iterator for WithOneOf<'a, I>
|
||||||
type Item = Result<FileLockEntry<'a>, TTE>;
|
where I: Iterator<Item = Result<FileLockEntry<'a>>>
|
||||||
|
{
|
||||||
|
type Item = Result<FileLockEntry<'a>>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
loop {
|
loop {
|
||||||
|
@ -69,14 +76,18 @@ impl<'a> Iterator for WithOneOf<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct WithNoneOf<'a> {
|
pub struct WithNoneOf<'a, I>
|
||||||
iter: GetTimeTrackIter<'a>,
|
where I: Iterator<Item = Result<FileLockEntry<'a>>>
|
||||||
|
{
|
||||||
|
iter: I,
|
||||||
disallowed_tags: &'a Vec<TTT>,
|
disallowed_tags: &'a Vec<TTT>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WithNoneOf<'a> {
|
impl<'a, I> WithNoneOf<'a, I>
|
||||||
|
where I: Iterator<Item = Result<FileLockEntry<'a>>>
|
||||||
|
{
|
||||||
|
|
||||||
pub fn new(iter: GetTimeTrackIter<'a>, disallowed_tags: &'a Vec<TTT>) -> WithNoneOf<'a> {
|
pub fn new(iter: I, disallowed_tags: &'a Vec<TTT>) -> WithNoneOf<'a, I> {
|
||||||
WithNoneOf {
|
WithNoneOf {
|
||||||
iter: iter,
|
iter: iter,
|
||||||
disallowed_tags: disallowed_tags
|
disallowed_tags: disallowed_tags
|
||||||
|
@ -84,8 +95,10 @@ impl<'a> WithNoneOf<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for WithNoneOf<'a> {
|
impl<'a, I> Iterator for WithNoneOf<'a, I>
|
||||||
type Item = Result<FileLockEntry<'a>, TTE>;
|
where I: Iterator<Item = Result<FileLockEntry<'a>>>
|
||||||
|
{
|
||||||
|
type Item = Result<FileLockEntry<'a>>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Reference in a new issue