2 #![allow(unused_must_use)]
4 // pretty-expanded FIXME #23616
7 fn next_match(&mut self) -> Option<(usize, usize)>;
10 struct CharPredMatcher<'a, 'b> {
12 pred: Box<dyn FnMut(char) -> bool + 'b>,
15 impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> {
16 fn next_match(&mut self) -> Option<(usize, usize)> {
21 trait IntoMatcher<'a, T> {
22 fn into_matcher(self, _: &'a str) -> T;
25 impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b {
26 fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> {
34 struct MatchIndices<M> {
38 impl<M: Matcher> Iterator for MatchIndices<M> {
39 type Item = (usize, usize);
41 fn next(&mut self) -> Option<(usize, usize)> {
42 self.matcher.next_match()
46 fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndices<M> {
47 let string_matcher = from.into_matcher(s);
48 MatchIndices { matcher: string_matcher }
53 match_indices(s, |c: char| c == 'b')