diff --git a/src/rule/collection/skip/option.rs b/src/rule/collection/skip/option.rs index 2e05b53..b551f16 100644 --- a/src/rule/collection/skip/option.rs +++ b/src/rule/collection/skip/option.rs @@ -1,8 +1,12 @@ mod no_skip; +mod skip_even_index; mod skip_first; +mod skip_odd_index; pub use no_skip::NoSkip; +pub use skip_even_index::SkipEvenIndex; pub use skip_first::SkipFirst; +pub use skip_odd_index::SkipOddIndex; pub trait SkipOption { type Item; diff --git a/src/rule/collection/skip/option/skip_even_index.rs b/src/rule/collection/skip/option/skip_even_index.rs new file mode 100644 index 0000000..44183b6 --- /dev/null +++ b/src/rule/collection/skip/option/skip_even_index.rs @@ -0,0 +1,13 @@ +use crate::rule::SkipOption; + +pub struct SkipEvenIndex { + _phantom_data: std::marker::PhantomData, +} + +impl SkipOption for SkipEvenIndex { + type Item = ITEM; + type Accumulator = (); + fn should_skip(i: usize, _: Option<&mut Self::Accumulator>, _: &Self::Item) -> bool { + i % 2 == 0 + } +} diff --git a/src/rule/collection/skip/option/skip_odd_index.rs b/src/rule/collection/skip/option/skip_odd_index.rs new file mode 100644 index 0000000..7a4b3ba --- /dev/null +++ b/src/rule/collection/skip/option/skip_odd_index.rs @@ -0,0 +1,13 @@ +use crate::rule::SkipOption; + +pub struct SkipOddIndex { + _phantom_data: std::marker::PhantomData, +} + +impl SkipOption for SkipOddIndex { + type Item = ITEM; + type Accumulator = (); + fn should_skip(i: usize, _: Option<&mut Self::Accumulator>, _: &Self::Item) -> bool { + i % 2 == 1 + } +}