diff --git a/src/rule/collection/skip.rs b/src/rule/collection/skip.rs index 08aef27..7a1f4e0 100644 --- a/src/rule/collection/skip.rs +++ b/src/rule/collection/skip.rs @@ -41,8 +41,9 @@ where let mut remains = target.into_iterator(); let mut result = VecDeque::new(); let (mut is_valid, mut message) = (true, String::new()); + let mut accumlator = None; for (i, item) in remains.by_ref().enumerate() { - if OPTION::should_skip(i, &item) { + if OPTION::should_skip(i, &item, accumlator.as_mut()) { result.push_back(item); continue; } diff --git a/src/rule/collection/skip/option.rs b/src/rule/collection/skip/option.rs index a77d126..0e3888d 100644 --- a/src/rule/collection/skip/option.rs +++ b/src/rule/collection/skip/option.rs @@ -6,5 +6,10 @@ pub use skip_first::SkipFirst; pub trait SkipOption { type Item; - fn should_skip(i: usize, item: &Self::Item) -> bool; + type Accumulator; + fn should_skip( + i: usize, + item: &Self::Item, + accumulator: Option<&mut Self::Accumulator>, + ) -> bool; } diff --git a/src/rule/collection/skip/option/no_skip.rs b/src/rule/collection/skip/option/no_skip.rs index bf62ec1..b87b765 100644 --- a/src/rule/collection/skip/option/no_skip.rs +++ b/src/rule/collection/skip/option/no_skip.rs @@ -6,7 +6,8 @@ pub struct NoSkip { impl SkipOption for NoSkip { type Item = ITEM; - fn should_skip(_: usize, _: &Self::Item) -> bool { + type Accumulator = (); + fn should_skip(_: usize, _: &Self::Item, _: Option<&mut Self::Accumulator>) -> bool { false } } diff --git a/src/rule/collection/skip/option/skip_first.rs b/src/rule/collection/skip/option/skip_first.rs index b5b638c..914ec52 100644 --- a/src/rule/collection/skip/option/skip_first.rs +++ b/src/rule/collection/skip/option/skip_first.rs @@ -6,7 +6,8 @@ pub struct SkipFirst { impl SkipOption for SkipFirst { type Item = ITEM; - fn should_skip(i: usize, _: &Self::Item) -> bool { + type Accumulator = (); + fn should_skip(i: usize, _: &Self::Item, _: Option<&mut Self::Accumulator>) -> bool { i == 0 } }