fn run_lookaround<Dir: Direction>(
        &mut self,
        input: &Input,
        ip: IP,
        pos: Input::Position,
        start_group: CaptureGroupID,
        end_group: CaptureGroupID,
        negate: bool,
    ) -> bool {
        // Copy capture groups, because if the match fails (or if we are inverted)
        // we need to restore these.
        let range = (start_group as usize)..(end_group as usize);
        // TODO: consider retaining storage here?
        // Temporarily defeat backtracking.
        let saved_groups = self.s.groups.iat(range.clone()).to_vec();

        // Start with an "empty" backtrack stack.
        // TODO: consider using a stack-allocated array.
        let mut saved_bts = vec![BacktrackInsn::Exhausted];
        core::mem::swap(&mut self.bts, &mut saved_bts);

        // Enter into the lookaround's instruction stream.
        let matched = self.try_at_pos(*input, ip, pos, Dir::new()).is_some();

        // Put back our bts.
        core::mem::swap(&mut self.bts, &mut saved_bts);

        // If we are a positive lookahead that successfully matched, retain the
        // capture groups (but we need to set up backtracking). Otherwise restore
        // them.
        if matched && !negate {
            for (idx, cg) in saved_groups.iter().enumerate() {
                debug_assert!(idx + (start_group as usize) < MAX_CAPTURE_GROUPS);
                self.push_backtrack(BacktrackInsn::SetCaptureGroup {
                    id: (idx as CaptureGroupID) + start_group,
                    data: *cg,
                });
            }
        } else {
            self.s.groups.splice(range, saved_groups);
        }
        matched != negate
    }
// Run a lookaround instruction, which is either forwards or backwards
// (according to Direction). The half-open range
// start_group..end_group is the range of contained capture groups.
// \return whether we matched and negate was false, or did not match but negate
// is true.
Run a lookaround instruction, which is either forwards or backwards
(according to Direction). The half-open range
start_group..end_group is the range of contained capture groups.
\return whether we matched and negate was false, or did not match but negate
is true.
Run a lookaround instruction which is either forwards or backwards ( according to Direction ) . The half - open range start_group .. end_group is the range of contained capture groups . \ return whether we matched and negate was false or did not match but negate is true .
fn run_lookaround<Dir: Direction>(
        &mut self,
        input: &Input,
        ip: IP,
        pos: Input::Position,
        start_group: CaptureGroupID,
        end_group: CaptureGroupID,
        negate: bool,
    ) -> bool {
        // Copy capture groups, because if the match fails (or if we are inverted)
        // we need to restore these.
        let range = (start_group as usize)..(end_group as usize);
        // TODO: consider retaining storage here?
        // Temporarily defeat backtracking.
        let saved_groups = self.s.groups.iat(range.clone()).to_vec();
        // Start with an "empty" backtrack stack.
        // TODO: consider using a stack-allocated array.
        let mut saved_bts = vec![BacktrackInsn::Exhausted];
        core::mem::swap(&mut self.bts, &mut saved_bts);
        // Enter into the lookaround's instruction stream.
        let matched = self.try_at_pos(*input, ip, pos, Dir::new()).is_some();
        // Put back our bts.
        core::mem::swap(&mut self.bts, &mut saved_bts);
        // If we are a positive lookahead that successfully matched, retain the
        // capture groups (but we need to set up backtracking). Otherwise restore
        // them.
        if matched && !negate {
            for (idx, cg) in saved_groups.iter().enumerate() {
                debug_assert!(idx + (start_group as usize) < MAX_CAPTURE_GROUPS);
                self.push_backtrack(BacktrackInsn::SetCaptureGroup {
                    id: (idx as CaptureGroupID) + start_group,
                    data: *cg,
                });
            }
        } else {
            self.s.groups.splice(range, saved_groups);
        }
        matched != negate
    }
fn run_lookaround < Dir : Direction > ( & mut self , input : & Input , ip : IP , pos : Input :: Position , start_group : CaptureGroupID , end_group : CaptureGroupID , negate : bool , ) -> bool { // Copy capture groups, because if the match fails (or if we are inverted) // we need to restore these. let range = ( start_group as usize ) .. ( end_group as usize ) ; // TODO: consider retaining storage here? // Temporarily defeat backtracking. let saved_groups = self . s . groups . iat ( range . clone ( ) ) . to_vec ( ) ; // Start with an "empty" backtrack stack. // TODO: consider using a stack-allocated array. let mut saved_bts = vec ! [ BacktrackInsn Exhausted ] ; core :: mem :: swap ( & mut self . bts , & mut saved_bts ) ; // Enter into the lookaround's instruction stream. let matched = self . try_at_pos ( * input , ip , pos , Dir :: new ( ) ) . is_some ( ) ; // Put back our bts. core :: mem :: swap ( & mut self . bts , & mut saved_bts ) ; // If we are a positive lookahead that successfully matched, retain the // capture groups (but we need to set up backtracking). Otherwise restore // them. if matched && ! negate { for ( idx , cg ) in saved_groups . iter ( ) . enumerate ( ) { debug_assert ! ( idx ( start_group as usize ) MAX_CAPTURE_GROUPS ) ; self . push_backtrack ( BacktrackInsn :: SetCaptureGroup { id : ( idx as CaptureGroupID ) + start_group , data : * cg , } ) ; } } else { self . s . groups . splice ( range , saved_groups ) ; } matched != negate }
Run a lookaround instruction, which is either forwards or backwards
(according to Direction).
Run a lookaround instruction which is either forwards or backwards ( according to Direction ) .
&mut self
input
&Input
ip
IP
pos
Input::Position
start_group
CaptureGroupID
end_group
CaptureGroupID
negate
bool