11use anyhow:: { Context as _, Error , Result } ;
22use git2:: Repository ;
3- use std:: { env, fs :: File , io :: Write , path:: Path } ;
3+ use std:: { env, path:: Path } ;
44
55fn main ( ) -> Result < ( ) > {
66 let out_dir = env:: var ( "OUT_DIR" ) . context ( "missing OUT_DIR" ) ?;
@@ -16,10 +16,11 @@ fn write_git_version(out_dir: &Path) -> Result<()> {
1616 let git_hash = maybe_hash. as_deref ( ) . unwrap_or ( "???????" ) ;
1717
1818 let build_date = time:: OffsetDateTime :: now_utc ( ) . date ( ) ;
19- let dest_path = out_dir. join ( "git_version" ) ;
2019
21- let mut file = File :: create ( & dest_path) ?;
22- write ! ( file, "({} {})" , git_hash, build_date) ?;
20+ std:: fs:: write (
21+ out_dir. join ( "git_version" ) ,
22+ format ! ( "({} {})" , git_hash, build_date) ,
23+ ) ?;
2324
2425 // TODO: are these right?
2526 println ! ( "cargo:rerun-if-changed=.git/HEAD" ) ;
@@ -78,8 +79,7 @@ fn compile_sass_file(
7879
7980 let css = context. compile ( ) . map_err ( Error :: msg) ?;
8081 let dest_path = out_dir. join ( format ! ( "{}.css" , target) ) ;
81- let mut file = File :: create ( & dest_path) ?;
82- file. write_all ( css. as_bytes ( ) ) ?;
82+ std:: fs:: write ( dest_path, css) ?;
8383
8484 Ok ( ( ) )
8585}
0 commit comments