fn parse_str(raw_operator: &str) -> Result<Self, String> {
        // Attempt to parse it as an exit code integer (we'll use that twice)
        let exit_code = raw_operator.parse::<i32>();
        let operator = match raw_operator {
            _ if exit_code.is_ok() => BonesOperator::ExitCode(exit_code.unwrap()),
            _ if raw_operator.starts_with('!') => {
                let exit_code_str = raw_operator.get(1..);
                let exit_code = match exit_code_str {
                    Some(exit_code) => match exit_code.parse::<i32>() {
                        Ok(exit_code) => exit_code,
                        Err(_) => return Err(format!("Couldn't parse exit code as 32-bit integer from `NotExitCode` operator invocation '{}'.", raw_operator))
                    },
                    None => return Err(format!("Couldn't extract exit code from `NotExitCode` operator invocation '{}'.", raw_operator))
                };
                BonesOperator::NotExitCode(exit_code)
            }
            // The next four are simple because they have no attached data
            "Any" => BonesOperator::Any,
            "None" => BonesOperator::None,
            "Success" => BonesOperator::Success,
            "Failure" => BonesOperator::Failure,
            // These require recursion
            _ if raw_operator.contains('|') => {
                let parts: Vec<&str> = raw_operator.split('|').collect();
                let mut operators: Vec<BonesOperator> = Vec::new();
                // Recursively parse each operator
                for part in parts {
                    operators.push(BonesOperator::parse_str(part)?)
                }
                BonesOperator::Union(operators)
            }
            _ if raw_operator.contains('+') => {
                let parts: Vec<&str> = raw_operator.split('+').collect();
                let mut operators: Vec<BonesOperator> = Vec::new();
                // Recursively parse each operator
                for part in parts {
                    operators.push(BonesOperator::parse_str(part)?)
                }
                BonesOperator::Intersection(operators)
            }
            _ => {
                return Err(format!(
                    "Unrecognized operator '{}' in Bones directive.",
                    raw_operator
                ))
            }
        };

        Ok(operator)
    }
// Parses a string operator given in a directive string into a fully-fledged variant
Parses a string operator given in a directive string into a fully-fledged variant
Parses a string operator given in a directive string into a fully - fledged variant
fn parse_str(raw_operator: &str) -> Result<Self, String> {
        // Attempt to parse it as an exit code integer (we'll use that twice)
        let exit_code = raw_operator.parse::<i32>();
        let operator = match raw_operator {
            _ if exit_code.is_ok() => BonesOperator::ExitCode(exit_code.unwrap()),
            _ if raw_operator.starts_with('!') => {
                let exit_code_str = raw_operator.get(1..);
                let exit_code = match exit_code_str {
                    Some(exit_code) => match exit_code.parse::<i32>() {
                        Ok(exit_code) => exit_code,
                        Err(_) => return Err(format!("Couldn't parse exit code as 32-bit integer from `NotExitCode` operator invocation '{}'.", raw_operator))
                    },
                    None => return Err(format!("Couldn't extract exit code from `NotExitCode` operator invocation '{}'.", raw_operator))
                };
                BonesOperator::NotExitCode(exit_code)
            }
            // The next four are simple because they have no attached data
            "Any" => BonesOperator::Any,
            "None" => BonesOperator::None,
            "Success" => BonesOperator::Success,
            "Failure" => BonesOperator::Failure,
            // These require recursion
            _ if raw_operator.contains('|') => {
                let parts: Vec<&str> = raw_operator.split('|').collect();
                let mut operators: Vec<BonesOperator> = Vec::new();
                // Recursively parse each operator
                for part in parts {
                    operators.push(BonesOperator::parse_str(part)?)
                }
                BonesOperator::Union(operators)
            }
            _ if raw_operator.contains('+') => {
                let parts: Vec<&str> = raw_operator.split('+').collect();
                let mut operators: Vec<BonesOperator> = Vec::new();
                // Recursively parse each operator
                for part in parts {
                    operators.push(BonesOperator::parse_str(part)?)
                }
                BonesOperator::Intersection(operators)
            }
            _ => {
                return Err(format!(
                    "Unrecognized operator '{}' in Bones directive.",
                    raw_operator
                ))
            }
        };
        Ok(operator)
    }
fn parse_str ( raw_operator : & str ) -> Result < Self , String > { // Attempt to parse it as an exit code integer (we'll use that twice) let exit_code = raw_operator . parse :: < i32 > ( ) ; let operator = match raw_operator { _ if exit_code . is_ok ( ) => BonesOperator :: ExitCode ( exit_code . unwrap ( ) ) , _ if raw_operator . starts_with ( '!' ) => { let exit_code_str = raw_operator . get ( 1 .. ) ; let exit_code = match exit_code_str { Some ( exit_code ) => match exit_code . parse :: < i32 > ( ) { Ok ( exit_code ) => exit_code , Err ( _ ) => return Err ( format ! ( " " raw_operator ) ) } , None => return Err ( format ! ( " " raw_operator ) ) } ; BonesOperator :: NotExitCode ( exit_code ) } // The next four are simple because they have no attached data " " => BonesOperator :: Any , " " => BonesOperator :: None , " " => BonesOperator :: Success , " " => BonesOperator :: Failure , // These require recursion _ if raw_operator . contains ( '|' ) => { let parts : Vec < & str > = raw_operator . split ( '|' ) . collect ( ) ; let mut operators : Vec < BonesOperator > = Vec :: new ( ) ; // Recursively parse each operator for part in parts { operators . push ( BonesOperator :: parse_str ( part ) ? ) } BonesOperator :: Union ( operators ) } _ if raw_operator . contains ( '+' ) => { let parts : Vec < & str > = raw_operator . split ( '+' ) . collect ( ) ; let mut operators : Vec < BonesOperator > = Vec :: new ( ) ; // Recursively parse each operator for part in parts { operators . push ( BonesOperator :: parse_str ( part ) ? ) } BonesOperator :: Intersection ( operators ) } _ => { return Err ( format ! ( " " raw_operator ) ) } } ; Ok ( operator ) }
Parses a string operator given in a directive string into a fully-fledged variant
Parses a string operator given in a directive string into a fully - fledged variant
raw_operator
&str