fn output_report(report: String, output_file: &str) {
    if output_file.len() == 0 {
        println!("{}", report);
    } else {
        let path = Path::new(output_file);
        let display = path.display();
        println!("Writing to file {:?}", display);

        let mut file = match File::create(&path) {
            Err(why) => panic!("couldn't create {}: {}", display, why),
            Ok(file) => file,
        };

        match file.write_all(report.as_bytes()) {
            Err(why) => panic!("couldn't write to {}: {}", display, why),
            Ok(_) => println!("successfully wrote to {}", display),
        }
    }
}
/**
 * Output the report, either to stdout or the requested file
 */
Output the report, either to stdout or the requested file
Output the report either to stdout or the requested file
fn output_report(report: String, output_file: &str) {
    if output_file.len() == 0 {
        println!("{}", report);
    } else {
        let path = Path::new(output_file);
        let display = path.display();
        println!("Writing to file {:?}", display);
        let mut file = match File::create(&path) {
            Err(why) => panic!("couldn't create {}: {}", display, why),
            Ok(file) => file,
        };
        match file.write_all(report.as_bytes()) {
            Err(why) => panic!("couldn't write to {}: {}", display, why),
            Ok(_) => println!("successfully wrote to {}", display),
        }
    }
}
fn output_report ( report : String , output_file : & str ) { if output_file . len ( ) == 0 { println ! ( " " report ) ; } else { let path = Path :: new ( output_file ) ; let display = path . display ( ) ; println ! ( " " display ) ; let mut file = match File :: create ( & path ) { Err ( why ) => panic ! ( " " display why ) , Ok ( file ) => file , } ; match file . write_all ( report . as_bytes ( ) ) { Err ( why ) => panic ! ( " " display why ) , Ok ( _ ) => println ! ( " " display ) , } } }
Output the report, either to stdout or the requested file
Output the report either to stdout or the requested file
report
String
output_file
&str