fn drop_helper(&mut self) -> Result<(), String> {
        // Kill the server
        self.mock_server.shutdown()?;

        // Look up any mismatches which occurred.
        let mismatches = self.mock_server.mismatches();

        if mismatches.is_empty() {
            // Success! Write out the generated pact file.
            self.mock_server.write_pact(&Some(env::var("PACT_OUTPUT_DIR").unwrap_or("target/pacts".to_owned())))
                .map_err(|err| format!("error writing pact: {}", err))?;
            Ok(())
        } else {
            // Failure. Format our errors.
            let mut msg = format!(
                "mock server {} failed verification:\n",
                self.description,
            );
            for mismatch in mismatches {
                match mismatch {
                    MatchResult::RequestMatch(_) => {
                        unreachable!("list of mismatches contains a match");
                    }
                    MatchResult::RequestMismatch(interaction, mismatches) => {
                        let _ = writeln!(
                            &mut msg,
                            "- interaction {:?}:",
                            interaction.description,
                        );
                        for m in mismatches {
                            let _ = writeln!(&mut msg, "  - {}", m.description());
                        }
                    }
                    MatchResult::RequestNotFound(request) => {
                        let _ = writeln!(&mut msg, "- received unexpected request:");
                        let _ = writeln!(&mut msg, "{:#?}", request);
                    }
                    MatchResult::MissingRequest(interaction) => {
                        let _ = writeln!(
                            &mut msg,
                            "- interaction {:?} expected, but never occurred",
                            interaction.description,
                        );
                        let _ = writeln!(&mut msg, "{:#?}", interaction.request);
                    }
                }
            }
            Err(msg)
        }
    }
/// Helper function called by our `drop` implementation. This basically exists
/// so that it can return `Err(message)` whenever needed without making the
/// flow control in `drop` ultra-complex.
Helper function called by our `drop` implementation. This basically exists
so that it can return `Err(message)` whenever needed without making the
flow control in `drop` ultra-complex.
Helper function called by our ` drop ` implementation . This basically exists so that it can return ` Err ( message ) ` whenever needed without making the flow control in ` drop ` ultra - complex .
fn drop_helper(&mut self) -> Result<(), String> {
        // Kill the server
        self.mock_server.shutdown()?;
        // Look up any mismatches which occurred.
        let mismatches = self.mock_server.mismatches();
        if mismatches.is_empty() {
            // Success! Write out the generated pact file.
            self.mock_server.write_pact(&Some(env::var("PACT_OUTPUT_DIR").unwrap_or("target/pacts".to_owned())))
                .map_err(|err| format!("error writing pact: {}", err))?;
            Ok(())
        } else {
            // Failure. Format our errors.
            let mut msg = format!(
                "mock server {} failed verification:\n",
                self.description,
            );
            for mismatch in mismatches {
                match mismatch {
                    MatchResult::RequestMatch(_) => {
                        unreachable!("list of mismatches contains a match");
                    }
                    MatchResult::RequestMismatch(interaction, mismatches) => {
                        let _ = writeln!(
                            &mut msg,
                            "- interaction {:?}:",
                            interaction.description,
                        );
                        for m in mismatches {
                            let _ = writeln!(&mut msg, "  - {}", m.description());
                        }
                    }
                    MatchResult::RequestNotFound(request) => {
                        let _ = writeln!(&mut msg, "- received unexpected request:");
                        let _ = writeln!(&mut msg, "{:#?}", request);
                    }
                    MatchResult::MissingRequest(interaction) => {
                        let _ = writeln!(
                            &mut msg,
                            "- interaction {:?} expected, but never occurred",
                            interaction.description,
                        );
                        let _ = writeln!(&mut msg, "{:#?}", interaction.request);
                    }
                }
            }
            Err(msg)
        }
    }
fn drop_helper ( & mut self ) -> Result < ( ) , String > { // Kill the server self . mock_server . shutdown ( ) ? ; // Look up any mismatches which occurred. let mismatches = self . mock_server . mismatches ( ) ; if mismatches . is_empty ( ) { // Success! Write out the generated pact file. self . mock_server . write_pact ( & Some ( env :: var ( " " ) . unwrap_or ( " " . to_owned ( ) ) ) ) . map_err ( | err | format ! ( " " err ) ) ? ; Ok ( ( ) ) } else { // Failure. Format our errors. let mut msg = format ! ( " \n " self description ) ; for mismatch in mismatches { match mismatch { MatchResult :: RequestMatch ( _ ) => { unreachable ! ( " " ) ; } MatchResult :: RequestMismatch ( interaction , mismatches ) => { let _ = writeln ! ( mut msg " " interaction description ) ; for m in mismatches { let _ = writeln ! ( mut msg " " m description ( ) ) ; } } MatchResult :: RequestNotFound ( request ) => { let _ = writeln ! ( mut msg " " ) ; let _ = writeln ! ( mut msg " " request ) ; } MatchResult :: MissingRequest ( interaction ) => { let _ = writeln ! ( mut msg " " interaction description ) ; let _ = writeln ! ( mut msg " " interaction request ) ; } } } Err ( msg ) } }
Helper function called by our `drop` implementation.
Helper function called by our ` drop ` implementation .
&mut self
&mut self