fn pursue_next_strand(&mut self, depth: StackIndex) -> RecursiveSearchResult<()> {
        // This is a bit complicated because this is where we handle cycles.
        let table = self.stack[depth].table;

        // Strands that encountered a cyclic error.
        let mut cyclic_strands = vec![];

        // The minimum of all cyclic strands.
        let mut cyclic_minimums = Minimums::MAX;

        loop {
            match self.tables[table].pop_next_strand() {
                Some(canonical_strand) => {
                    let num_universes = CO::num_universes(&self.tables[table].table_goal);
                    let result = Self::with_instantiated_strand(
                        self.context.clone(),
                        num_universes,
                        &canonical_strand,
                        PursueStrand {
                            forest: self,
                            depth,
                        },
                    );
                    match result {
                        Ok(answer) => {
                            // Now that we produced an answer, these
                            // cyclic strands need to be retried.
                            self.tables[table].extend_strands(cyclic_strands);
                            return Ok(answer);
                        }

                        Err(StrandFail::NoSolution) | Err(StrandFail::QuantumExceeded) => {
                            // This strand did not produce an answer,
                            // but either it (or some other, pending
                            // strands) may do so in the
                            // future. Enqueue the cyclic strands to
                            // be retried after that point.
                            self.tables[table].extend_strands(cyclic_strands);
                            return Err(RecursiveSearchFail::QuantumExceeded);
                        }

                        Err(StrandFail::Cycle(canonical_strand, strand_minimums)) => {
                            // This strand encountered a cycle. Stash
                            // it for later and try the next one until
                            // we know that *all* available strands
                            // are hitting a cycle.
                            cyclic_strands.push(canonical_strand);
                            cyclic_minimums.take_minimums(&strand_minimums);
                        }
                    }
                }

                None => {
                    // No more strands left to try! That means either we started
                    // with no strands, or all available strands encountered a cycle.

                    if cyclic_strands.is_empty() {
                        // We started with no strands!
                        return Err(RecursiveSearchFail::NoMoreSolutions);
                    } else {
                        let c = mem::replace(&mut cyclic_strands, vec![]);
                        if let Some(err) = self.cycle(depth, c, cyclic_minimums) {
                            return Err(err);
                        }
                    }
                }
            }
        }
    }
/// Selects the next eligible strand from the table at depth
/// `depth` and pursues it. If that strand encounters a cycle,
/// then this function will loop and keep trying strands until it
/// reaches one that did not encounter a cycle; that result is
/// propagated.  If all strands return a cycle, then the entire
/// subtree is "completed" by invoking `cycle`.
Selects the next eligible strand from the table at depth
`depth` and pursues it. If that strand encounters a cycle,
then this function will loop and keep trying strands until it
reaches one that did not encounter a cycle; that result is
propagated.  If all strands return a cycle, then the entire
subtree is "completed" by invoking `cycle`.
Selects the next eligible strand from the table at depth ` depth ` and pursues it . If that strand encounters a cycle then this function will loop and keep trying strands until it reaches one that did not encounter a cycle ; that result is propagated . If all strands return a cycle then the entire subtree is " completed " by invoking ` cycle ` .
fn pursue_next_strand(&mut self, depth: StackIndex) -> RecursiveSearchResult<()> {
        // This is a bit complicated because this is where we handle cycles.
        let table = self.stack[depth].table;
        // Strands that encountered a cyclic error.
        let mut cyclic_strands = vec![];
        // The minimum of all cyclic strands.
        let mut cyclic_minimums = Minimums::MAX;
        loop {
            match self.tables[table].pop_next_strand() {
                Some(canonical_strand) => {
                    let num_universes = CO::num_universes(&self.tables[table].table_goal);
                    let result = Self::with_instantiated_strand(
                        self.context.clone(),
                        num_universes,
                        &canonical_strand,
                        PursueStrand {
                            forest: self,
                            depth,
                        },
                    );
                    match result {
                        Ok(answer) => {
                            // Now that we produced an answer, these
                            // cyclic strands need to be retried.
                            self.tables[table].extend_strands(cyclic_strands);
                            return Ok(answer);
                        }
                        Err(StrandFail::NoSolution) | Err(StrandFail::QuantumExceeded) => {
                            // This strand did not produce an answer,
                            // but either it (or some other, pending
                            // strands) may do so in the
                            // future. Enqueue the cyclic strands to
                            // be retried after that point.
                            self.tables[table].extend_strands(cyclic_strands);
                            return Err(RecursiveSearchFail::QuantumExceeded);
                        }
                        Err(StrandFail::Cycle(canonical_strand, strand_minimums)) => {
                            // This strand encountered a cycle. Stash
                            // it for later and try the next one until
                            // we know that *all* available strands
                            // are hitting a cycle.
                            cyclic_strands.push(canonical_strand);
                            cyclic_minimums.take_minimums(&strand_minimums);
                        }
                    }
                }
                None => {
                    // No more strands left to try! That means either we started
                    // with no strands, or all available strands encountered a cycle.
                    if cyclic_strands.is_empty() {
                        // We started with no strands!
                        return Err(RecursiveSearchFail::NoMoreSolutions);
                    } else {
                        let c = mem::replace(&mut cyclic_strands, vec![]);
                        if let Some(err) = self.cycle(depth, c, cyclic_minimums) {
                            return Err(err);
                        }
                    }
                }
            }
        }
    }
fn pursue_next_strand ( & mut self , depth : StackIndex ) -> RecursiveSearchResult < ( ) > { // This is a bit complicated because this is where we handle cycles. let table = self . stack [ depth ] . table ; // Strands that encountered a cyclic error. let mut cyclic_strands = vec ! [ ] ; // The minimum of all cyclic strands. let mut cyclic_minimums = Minimums :: MAX ; loop { match self . tables [ table ] . pop_next_strand ( ) { Some ( canonical_strand ) => { let num_universes = CO :: num_universes ( & self . tables [ table ] . table_goal ) ; let result = Self :: with_instantiated_strand ( self . context . clone ( ) , num_universes , & canonical_strand , PursueStrand { forest : self , depth , } , ) ; match result { Ok ( answer ) => { // Now that we produced an answer, these // cyclic strands need to be retried. self . tables [ table ] . extend_strands ( cyclic_strands ) ; return Ok ( answer ) ; } Err ( StrandFail :: NoSolution ) | Err ( StrandFail :: QuantumExceeded ) => { // This strand did not produce an answer, // but either it (or some other, pending // strands) may do so in the // future. Enqueue the cyclic strands to // be retried after that point. self . tables [ table ] . extend_strands ( cyclic_strands ) ; return Err ( RecursiveSearchFail :: QuantumExceeded ) ; } Err ( StrandFail :: Cycle ( canonical_strand , strand_minimums ) ) => { // This strand encountered a cycle. Stash // it for later and try the next one until // we know that *all* available strands // are hitting a cycle. cyclic_strands . push ( canonical_strand ) ; cyclic_minimums . take_minimums ( & strand_minimums ) ; } } } None => { // No more strands left to try! That means either we started // with no strands, or all available strands encountered a cycle. if cyclic_strands . is_empty ( ) { // We started with no strands! return Err ( RecursiveSearchFail :: NoMoreSolutions ) ; } else { let c = mem :: replace ( & mut cyclic_strands , vec ! [ ] ) ; if let Some ( err ) = self . cycle ( depth , c , cyclic_minimums ) { return Err ( err ) ; } } } } } }
Selects the next eligible strand from the table at depth
`depth` and pursues it.
Selects the next eligible strand from the table at depth ` depth ` and pursues it .
&mut self
depth
StackIndex
&mut self
depth
StackIndex