fn matches(&self, exit_code: &i32) -> bool {
        // This can be recursive due to the `Union` an d`Intersection` variants
        fn matches(exit_code: &i32, variant: &BonesOperator) -> bool {
            // Go through each different type of operator possible
            match variant {
                BonesOperator::Success => *exit_code == 0,
                BonesOperator::Failure => *exit_code != 0,
                BonesOperator::ExitCode(comparison) => exit_code == comparison,
                BonesOperator::NotExitCode(comparison) => exit_code != comparison,
                BonesOperator::Any => true,
                BonesOperator::None => false,
                BonesOperator::Union(operators) => {
                    let mut is_match = false;
                    for operator in operators {
                        let op_matches = operator.matches(exit_code);
                        // We only need one of them to be true
                        if op_matches {
                            is_match = true;
                            break;
                        }
                    }
                    is_match
                }
                BonesOperator::Intersection(operators) => {
                    let mut is_match = false;
                    for operator in operators {
                        let op_matches = operator.matches(exit_code);
                        // We only need one of them to be false (aka. all of them have to be true)
                        is_match = op_matches;
                        if !op_matches {
                            break;
                        }
                    }
                    is_match
                }
            }
        }

        matches(exit_code, self)
    }
// Checks if the given exit code matches this operator
Checks if the given exit code matches this operator
Checks if the given exit code matches this operator
fn matches(&self, exit_code: &i32) -> bool {
        // This can be recursive due to the `Union` an d`Intersection` variants
        fn matches(exit_code: &i32, variant: &BonesOperator) -> bool {
            // Go through each different type of operator possible
            match variant {
                BonesOperator::Success => *exit_code == 0,
                BonesOperator::Failure => *exit_code != 0,
                BonesOperator::ExitCode(comparison) => exit_code == comparison,
                BonesOperator::NotExitCode(comparison) => exit_code != comparison,
                BonesOperator::Any => true,
                BonesOperator::None => false,
                BonesOperator::Union(operators) => {
                    let mut is_match = false;
                    for operator in operators {
                        let op_matches = operator.matches(exit_code);
                        // We only need one of them to be true
                        if op_matches {
                            is_match = true;
                            break;
                        }
                    }
                    is_match
                }
                BonesOperator::Intersection(operators) => {
                    let mut is_match = false;
                    for operator in operators {
                        let op_matches = operator.matches(exit_code);
                        // We only need one of them to be false (aka. all of them have to be true)
                        is_match = op_matches;
                        if !op_matches {
                            break;
                        }
                    }
                    is_match
                }
            }
        }
        matches(exit_code, self)
    }
fn matches ( & self , exit_code : & i32 ) -> bool { // This can be recursive due to the `Union` an d`Intersection` variants fn matches ( exit_code : & i32 , variant : & BonesOperator ) -> bool { // Go through each different type of operator possible match variant { BonesOperator :: Success => * exit_code == 0 , BonesOperator :: Failure => * exit_code != 0 , BonesOperator :: ExitCode ( comparison ) => exit_code == comparison , BonesOperator :: NotExitCode ( comparison ) => exit_code != comparison , BonesOperator :: Any => true , BonesOperator :: None => false , BonesOperator :: Union ( operators ) => { let mut is_match = false ; for operator in operators { let op_matches = operator . matches ( exit_code ) ; // We only need one of them to be true if op_matches { is_match = true ; break ; } } is_match } BonesOperator :: Intersection ( operators ) => { let mut is_match = false ; for operator in operators { let op_matches = operator . matches ( exit_code ) ; // We only need one of them to be false (aka. all of them have to be true) is_match = op_matches ; if ! op_matches { break ; } } is_match } } } matches ( exit_code , self ) }
Checks if the given exit code matches this operator
Checks if the given exit code matches this operator
&self
exit_code
&i32