Add traits for using iterator filtering

This commit is contained in:
Matthias Beyer 2017-07-15 16:37:38 +02:00
parent 797ce777b7
commit cb51e2f5ef

View file

@ -75,6 +75,19 @@ impl<'a, I> Iterator for WithOneOf<'a, I>
}
}
pub trait WithOneOfTags<'a> : Sized + Iterator<Item = Result<FileLockEntry<'a>>> {
fn with_timetracking_tags(self, tags: &'a Vec<TTT>) -> WithOneOf<'a, Self>;
}
impl<'a, I> WithOneOfTags<'a> for I
where I: Iterator<Item = Result<FileLockEntry<'a>>>,
Self: Sized
{
fn with_timetracking_tags(self, tags: &'a Vec<TTT>) -> WithOneOf<'a, Self> {
WithOneOf::new(self, tags)
}
}
pub struct WithNoneOf<'a, I>
where I: Iterator<Item = Result<FileLockEntry<'a>>>
@ -120,3 +133,16 @@ impl<'a, I> Iterator for WithNoneOf<'a, I>
}
}
pub trait WithNoneOfTags<'a> : Sized + Iterator<Item = Result<FileLockEntry<'a>>> {
fn without_timetracking_tags(self, tags: &'a Vec<TTT>) -> WithNoneOf<'a, Self>;
}
impl<'a, I> WithNoneOfTags<'a> for I
where I: Iterator<Item = Result<FileLockEntry<'a>>>,
Self: Sized
{
fn without_timetracking_tags(self, tags: &'a Vec<TTT>) -> WithNoneOf<'a, Self> {
WithNoneOf::new(self, tags)
}
}