fn handle_cffi_call_result(
    python: &Path,
    tempdir: TempDir,
    ffi_py: &PathBuf,
    output: &Output,
) -> Result<String> {
    if !output.status.success() {
        bail!(
            "Failed to generate cffi declarations using {}: {}\n--- Stdout:\n{}\n--- Stderr:\n{}",
            python.display(),
            output.status,
            str::from_utf8(&output.stdout)?,
            str::from_utf8(&output.stderr)?,
        );
    } else {
        // Don't swallow warnings
        std::io::stderr().write_all(&output.stderr)?;

        let ffi_py_content = fs::read_to_string(&ffi_py)?;
        tempdir.close()?;
        Ok(ffi_py_content)
    }
}
/// Extracted into a function because this is needed twice
Extracted into a function because this is needed twice
Extracted into a function because this is needed twice
fn handle_cffi_call_result(
    python: &Path,
    tempdir: TempDir,
    ffi_py: &PathBuf,
    output: &Output,
) -> Result<String> {
    if !output.status.success() {
        bail!(
            "Failed to generate cffi declarations using {}: {}\n--- Stdout:\n{}\n--- Stderr:\n{}",
            python.display(),
            output.status,
            str::from_utf8(&output.stdout)?,
            str::from_utf8(&output.stderr)?,
        );
    } else {
        // Don't swallow warnings
        std::io::stderr().write_all(&output.stderr)?;
        let ffi_py_content = fs::read_to_string(&ffi_py)?;
        tempdir.close()?;
        Ok(ffi_py_content)
    }
}
fn handle_cffi_call_result ( python : & Path , tempdir : TempDir , ffi_py : & PathBuf , output : & Output , ) -> Result < String > { if ! output . status . success ( ) { bail ! ( " \n \n \n \n " python display ( ) output status str from_utf8 ( output stdout ) str from_utf8 ( output stderr ) ) ; } else { // Don't swallow warnings std :: io :: stderr ( ) . write_all ( & output . stderr ) ? ; let ffi_py_content = fs :: read_to_string ( & ffi_py ) ? ; tempdir . close ( ) ? ; Ok ( ffi_py_content ) } }
Extracted into a function because this is needed twice
Extracted into a function because this is needed twice
python
&Path
tempdir
TempDir
ffi_py
&PathBuf
output
&Output
python
&Path
tempdir
TempDir
ffi_py
&PathBuf
output
&Output