oni_comb_parser_rs/core/
parser_filter.rs1use crate::core::parser_runner::ParserRunner;
2use crate::core::Element;
3
4pub trait ParserFilter<'a>: ParserRunner<'a> {
5 fn with_filter<F>(self, f: F) -> Self
7 where
8 F: Fn(&Self::Output) -> bool + 'a,
9 Self::Input: Element,
10 Self::Output: Clone + 'a,
11 Self: Sized;
12
13 fn with_filter_not<F>(self, f: F) -> Self
15 where
16 F: Fn(&Self::Output) -> bool + 'a,
17 Self::Input: Element,
18 Self::Output: Clone + 'a,
19 Self: Sized, {
20 self.with_filter(move |e| !f(e))
21 }
22}