fn inplace_modify_file<F: FnOnce(String) -> String>(path: &Path, func: F) {
    let mut contents = String::new();
    File::open(&path)
        .unwrap()
        .read_to_string(&mut contents)
        .unwrap();
    let new_contents = func(contents);
    File::create(&path)
        .unwrap()
        .write_all(new_contents.as_bytes())
        .unwrap();
}
// Opens a file, calls 'func' with its contents and writes the new content back.
Opens a file, calls 'func' with its contents and writes the new content back.
Opens a file calls ' func ' with its contents and writes the new content back .
fn inplace_modify_file<F: FnOnce(String) -> String>(path: &Path, func: F) {
    let mut contents = String::new();
    File::open(&path)
        .unwrap()
        .read_to_string(&mut contents)
        .unwrap();
    let new_contents = func(contents);
    File::create(&path)
        .unwrap()
        .write_all(new_contents.as_bytes())
        .unwrap();
}
fn inplace_modify_file < F : FnOnce ( String ) -> String > ( path : & Path , func : F ) { let mut contents = String :: new ( ) ; File :: open ( & path ) . unwrap ( ) . read_to_string ( & mut contents ) . unwrap ( ) ; let new_contents = func ( contents ) ; File :: create ( & path ) . unwrap ( ) . write_all ( new_contents . as_bytes ( ) ) . unwrap ( ) ; }
Opens a file, calls 'func' with its contents and writes the new content back.
Opens a file calls ' func ' with its contents and writes the new content back .
path
&Path
func
F
path
&Path
func
F