oni_comb_parser_rs/core/
parser_filter.rs

1use crate::core::parser_runner::ParserRunner;
2use crate::core::Element;
3
4pub trait ParserFilter<'a>: ParserRunner<'a> {
5  /// 解析結果をフィルターする[Parser]を返す。
6  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  /// 解析結果をフィルターする[Parser]を返す。
14  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}