1
1
use anyhow:: { Context as _, Error , Result } ;
2
2
use git2:: Repository ;
3
- use std:: { env, fs :: File , io :: Write , path:: Path } ;
3
+ use std:: { env, path:: Path } ;
4
4
5
5
fn main ( ) -> Result < ( ) > {
6
6
let out_dir = env:: var ( "OUT_DIR" ) . context ( "missing OUT_DIR" ) ?;
@@ -16,10 +16,11 @@ fn write_git_version(out_dir: &Path) -> Result<()> {
16
16
let git_hash = maybe_hash. as_deref ( ) . unwrap_or ( "???????" ) ;
17
17
18
18
let build_date = time:: OffsetDateTime :: now_utc ( ) . date ( ) ;
19
- let dest_path = out_dir. join ( "git_version" ) ;
20
19
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
+ ) ?;
23
24
24
25
// TODO: are these right?
25
26
println ! ( "cargo:rerun-if-changed=.git/HEAD" ) ;
@@ -78,8 +79,7 @@ fn compile_sass_file(
78
79
79
80
let css = context. compile ( ) . map_err ( Error :: msg) ?;
80
81
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) ?;
83
83
84
84
Ok ( ( ) )
85
85
}
0 commit comments