fn match_pairs_under_assumption(&mut self,
                                    test_lvalue: &Lvalue<'tcx>,
                                    test_kind: &TestKind<'tcx>,
                                    test_outcome: usize,
                                    match_pairs: Vec<MatchPair<'tcx>>)
                                    -> Option<Vec<MatchPair<'tcx>>> {
        let mut result = vec![];

        for match_pair in match_pairs {
            // if the match pair is testing a different lvalue, it
            // is unaffected by this test.
            if match_pair.lvalue != *test_lvalue {
                result.push(match_pair);
                continue;
            }

            // if this test doesn't tell us anything about this match-pair, then hang onto it.
            if !self.test_informs_match_pair(&match_pair, test_kind, test_outcome) {
                result.push(match_pair);
                continue;
            }

            // otherwise, build up the consequence match pairs
            let opt_consequent_match_pairs =
                self.consequent_match_pairs_under_assumption(match_pair,
                                                             test_kind,
                                                             test_outcome);
            match opt_consequent_match_pairs {
                None => {
                    // Right kind of test, but wrong outcome. That
                    // means this **entire candidate** is
                    // inapplicable, since the candidate is only
                    // applicable if all of its match-pairs apply (and
                    // this one doesn't).
                    return None;
                }

                Some(consequent_match_pairs) => {
                    // Test passed; add any new patterns we have to test to the final result.
                    result.extend(consequent_match_pairs)
                }
            }
        }

        Some(result)
    }
/// Helper for candidate_under_assumption that does the actual
/// work of transforming the list of match pairs.
Helper for candidate_under_assumption that does the actual
work of transforming the list of match pairs.
Helper for candidate_under_assumption that does the actual work of transforming the list of match pairs .
fn match_pairs_under_assumption(&mut self,
                                    test_lvalue: &Lvalue<'tcx>,
                                    test_kind: &TestKind<'tcx>,
                                    test_outcome: usize,
                                    match_pairs: Vec<MatchPair<'tcx>>)
                                    -> Option<Vec<MatchPair<'tcx>>> {
        let mut result = vec![];
        for match_pair in match_pairs {
            // if the match pair is testing a different lvalue, it
            // is unaffected by this test.
            if match_pair.lvalue != *test_lvalue {
                result.push(match_pair);
                continue;
            }
            // if this test doesn't tell us anything about this match-pair, then hang onto it.
            if !self.test_informs_match_pair(&match_pair, test_kind, test_outcome) {
                result.push(match_pair);
                continue;
            }
            // otherwise, build up the consequence match pairs
            let opt_consequent_match_pairs =
                self.consequent_match_pairs_under_assumption(match_pair,
                                                             test_kind,
                                                             test_outcome);
            match opt_consequent_match_pairs {
                None => {
                    // Right kind of test, but wrong outcome. That
                    // means this **entire candidate** is
                    // inapplicable, since the candidate is only
                    // applicable if all of its match-pairs apply (and
                    // this one doesn't).
                    return None;
                }
                Some(consequent_match_pairs) => {
                    // Test passed; add any new patterns we have to test to the final result.
                    result.extend(consequent_match_pairs)
                }
            }
        }
        Some(result)
    }
fn match_pairs_under_assumption ( & mut self , test_lvalue : & Lvalue < ' tcx > , test_kind : & TestKind < ' tcx > , test_outcome : usize , match_pairs : Vec < MatchPair < ' tcx > > ) -> Option < Vec < MatchPair < ' tcx > > > { let mut result = vec ! [ ] ; for match_pair in match_pairs { // if the match pair is testing a different lvalue, it // is unaffected by this test. if match_pair . lvalue != * test_lvalue { result . push ( match_pair ) ; continue ; } // if this test doesn't tell us anything about this match-pair, then hang onto it. if ! self . test_informs_match_pair ( & match_pair , test_kind , test_outcome ) { result . push ( match_pair ) ; continue ; } // otherwise, build up the consequence match pairs let opt_consequent_match_pairs = self . consequent_match_pairs_under_assumption ( match_pair , test_kind , test_outcome ) ; match opt_consequent_match_pairs { None => { // Right kind of test, but wrong outcome. That // means this **entire candidate** is // inapplicable, since the candidate is only // applicable if all of its match-pairs apply (and // this one doesn't). return None ; } Some ( consequent_match_pairs ) => { // Test passed; add any new patterns we have to test to the final result. result . extend ( consequent_match_pairs ) } } } Some ( result ) }
Helper for candidate_under_assumption that does the actual
work of transforming the list of match pairs.
Helper for candidate_under_assumption that does the actual work of transforming the list of match pairs .
&mut self
test_lvalue
&Lvalue<'tcx>
test_kind
&TestKind<'tcx>
test_outcome
usize
match_pairs
Vec<MatchPair<'tcx>>