File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ use serde::de::DeserializeOwned;
2
2
use serde:: Serialize ;
3
3
use std:: ffi:: OsStr ;
4
4
use std:: fs:: { self , File } ;
5
- use std:: io:: Read ;
6
5
use std:: path:: Path ;
7
6
use walkdir:: { DirEntry , WalkDir } ;
8
7
@@ -15,12 +14,10 @@ where
15
14
P : AsRef < Path > + ?Sized ,
16
15
{
17
16
let path = path. as_ref ( ) ;
18
- let mut f = File :: open ( path) . map_err ( |inner| Error :: AccessError {
17
+ let string = std :: fs :: read_to_string ( path) . map_err ( |inner| Error :: AccessError {
19
18
inner,
20
19
path : path. to_owned ( ) ,
21
20
} ) ?;
22
- let mut string = String :: new ( ) ;
23
- let _ = f. read_to_string ( & mut string) ;
24
21
let result: A = serde_json:: from_str ( string. as_str ( ) ) . map_err ( |inner| Error :: SerdeError {
25
22
inner,
26
23
path : path. to_owned ( ) ,
44
41
fs:: create_dir_all ( path. as_ref ( ) ) . map_err ( |inner| Error :: AccessError {
45
42
inner,
46
43
path : path. as_ref ( ) . to_owned ( ) ,
47
- } ) ?;
48
- Ok ( ( ) )
44
+ } )
49
45
}
50
46
51
47
pub fn cp ( from : & Path , to : & Path ) -> Result < ( ) > {
You can’t perform that action at this time.
0 commit comments