fn wrap_file_contents(target_dir: &Path, file_name_without_suffix: &str) {
    let generated_file = target_dir
        .join(file_name_without_suffix)
        .with_extension("rs");

    let contents = fs::read_to_string(&generated_file)
        .unwrap_or_else(|_| panic!("should read {}", generated_file.display()));
    fs::write(
        &generated_file,
        &format!(
            "pub mod {} {{ {}\n\n{}\n}}",
            file_name_without_suffix, WORKAROUND_COMMENT, contents
        ),
    )
    .unwrap_or_else(|_| panic!("should write {}", generated_file.display()));
}
// The generated file needs to be sourced via `include!` which doesn't work where the file has top-
// level inner attributes (see https://github.com/rust-lang/rfcs/issues/752).
//
// To work around this issue, we add 'pub mod proto { }' around the contents.
The generated file needs to be sourced via `include!` which doesn't work where the file has top
level inner attributes .

To work around this issue, we add 'pub mod proto { }' around the contents.
The generated file needs to be sourced via ` include! ` which doesn ' t work where the file has top level inner attributes . To work around this issue we add ' pub mod proto { } ' around the contents .
fn wrap_file_contents(target_dir: &Path, file_name_without_suffix: &str) {
    let generated_file = target_dir
        .join(file_name_without_suffix)
        .with_extension("rs");
    let contents = fs::read_to_string(&generated_file)
        .unwrap_or_else(|_| panic!("should read {}", generated_file.display()));
    fs::write(
        &generated_file,
        &format!(
            "pub mod {} {{ {}\n\n{}\n}}",
            file_name_without_suffix, WORKAROUND_COMMENT, contents
        ),
    )
    .unwrap_or_else(|_| panic!("should write {}", generated_file.display()));
}
fn wrap_file_contents ( target_dir : & Path , file_name_without_suffix : & str ) { let generated_file = target_dir . join ( file_name_without_suffix ) . with_extension ( " " ) ; let contents = fs :: read_to_string ( & generated_file ) . unwrap_or_else ( | _ | panic ! ( " " generated_file display ( ) ) ) ; fs :: write ( & generated_file , & format ! ( " \n \n \n " file_name_without_suffix WORKAROUND_COMMENT contents ) , ) . unwrap_or_else ( | _ | panic ! ( " " generated_file display ( ) ) ) ; }
The generated file needs to be sourced via `include!` which doesn't work where the file has top
level inner attributes (see https://github.com/rust-lang/rfcs/issues/752).
The generated file needs to be sourced via ` include! ` which doesn ' t work where the file has top level inner attributes ( see https : // github . com / rust - lang / rfcs / issues / 752 ) .
target_dir
&Path
file_name_without_suffix
&str
target_dir
&Path
file_name_without_suffix
&str