From cb51e2f5efcd78779e98f086c45702e5238f7dab Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 15 Jul 2017 16:37:38 +0200 Subject: [PATCH] Add traits for using iterator filtering --- libimagentrytimetrack/src/iter/filter.rs | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libimagentrytimetrack/src/iter/filter.rs b/libimagentrytimetrack/src/iter/filter.rs index 6fc24a3d..151d99aa 100644 --- a/libimagentrytimetrack/src/iter/filter.rs +++ b/libimagentrytimetrack/src/iter/filter.rs @@ -75,6 +75,19 @@ impl<'a, I> Iterator for WithOneOf<'a, I> } } +pub trait WithOneOfTags<'a> : Sized + Iterator>> { + fn with_timetracking_tags(self, tags: &'a Vec) -> WithOneOf<'a, Self>; +} + +impl<'a, I> WithOneOfTags<'a> for I + where I: Iterator>>, + Self: Sized +{ + fn with_timetracking_tags(self, tags: &'a Vec) -> WithOneOf<'a, Self> { + WithOneOf::new(self, tags) + } +} + pub struct WithNoneOf<'a, I> where I: Iterator>> @@ -120,3 +133,16 @@ impl<'a, I> Iterator for WithNoneOf<'a, I> } } +pub trait WithNoneOfTags<'a> : Sized + Iterator>> { + fn without_timetracking_tags(self, tags: &'a Vec) -> WithNoneOf<'a, Self>; +} + +impl<'a, I> WithNoneOfTags<'a> for I + where I: Iterator>>, + Self: Sized +{ + fn without_timetracking_tags(self, tags: &'a Vec) -> WithNoneOf<'a, Self> { + WithNoneOf::new(self, tags) + } +} +