fn write_if_changed(path: &Path, content: &str) {
    let changed = if !path.exists() {
        true
    } else {
        match std::fs::read_to_string(path) {
            Ok(old_content) => old_content != content,
            Err(_) => true,
        }
    };

    if changed {
        std::fs::write(path, content)
            .map_err(|e| format!("Error writing to {:?}: {}", path, e))
            .unwrap();
    }
}
/// Write content to file if it is different to the current content.
///
/// This prevents us from touching the file and modifying the `mtime` so that Cargo will re-compile the output `.rs`
/// file every time. Also see [`rust-lang/cargo#6529`](https://github.com/rust-lang/cargo/issues/6529).
Write content to file if it is different to the current content.
This prevents us from touching the file and modifying the `mtime` so that Cargo will re-compile the output `.rs`
file every time.
Write content to file if it is different to the current content . This prevents us from touching the file and modifying the ` mtime ` so that Cargo will re - compile the output ` . rs ` file every time .
fn write_if_changed(path: &Path, content: &str) {
    let changed = if !path.exists() {
        true
    } else {
        match std::fs::read_to_string(path) {
            Ok(old_content) => old_content != content,
            Err(_) => true,
        }
    };
    if changed {
        std::fs::write(path, content)
            .map_err(|e| format!("Error writing to {:?}: {}", path, e))
            .unwrap();
    }
}
fn write_if_changed ( path : & Path , content : & str ) { let changed = if ! path . exists ( ) { true } else { match std :: fs :: read_to_string ( path ) { Ok ( old_content ) => old_content != content , Err ( _ ) => true , } } ; if changed { std :: fs :: write ( path , content ) . map_err ( | e | format ! ( " " path e ) ) . unwrap ( ) ; } }
Write content to file if it is different to the current content.
Write content to file if it is different to the current content .
path
&Path
content
&str
path
&Path
content
&str