Leftmost search starting no earlier than `from`. */
(&self, root: &Node, ngroups: usize, from: usize)
| 39 | |
| 40 | /* Leftmost search starting no earlier than `from`. */ |
| 41 | pub fn search_from(&self, root: &Node, ngroups: usize, from: usize) -> Option<Caps> { |
| 42 | self.steps.set(0); |
| 43 | for start in from..=self.input.len() { |
| 44 | if self.exceeded() { break; } // stop scanning once the budget is gone |
| 45 | let mut caps: Caps = empty_caps(ngroups); |
| 46 | let mut found: Option<usize> = None; |
| 47 | self.m(root, start, &mut caps, &mut |end, _| { found = Some(end); true }); |
| 48 | if let Some(end) = found { |
| 49 | caps[0] = Some((start, end)); |
| 50 | return Some(caps); |
| 51 | } |
| 52 | } |
| 53 | None |
| 54 | } |
| 55 | |
| 56 | /* Anchored match at position zero, optionally requiring full consumption. */ |
| 57 | pub fn match_at(&self, root: &Node, ngroups: usize, full: bool) -> Option<Caps> { |