@@ -4,8 +4,7 @@ use rust_playground_top_crates::*;
4
4
use serde:: Serialize ;
5
5
use std:: {
6
6
collections:: BTreeMap ,
7
- fs:: File ,
8
- io:: { Read , Write } ,
7
+ fs:: { self , File } ,
9
8
path:: { Path , PathBuf } ,
10
9
} ;
11
10
@@ -14,9 +13,7 @@ use std::{
14
13
struct TomlManifest {
15
14
package : TomlPackage ,
16
15
profile : Profiles ,
17
- #[ serde( serialize_with = "toml::ser::tables_last" ) ]
18
16
dependencies : BTreeMap < String , DependencySpec > ,
19
- #[ serde( serialize_with = "toml::ser::tables_last" ) ]
20
17
build_dependencies : BTreeMap < String , DependencySpec > ,
21
18
}
22
19
@@ -54,15 +51,11 @@ struct Profiles {
54
51
}
55
52
56
53
fn main ( ) {
57
- let mut f =
58
- File :: open ( "crate-modifications.toml" ) . expect ( "unable to open crate modifications file" ) ;
59
-
60
- let mut d = Vec :: new ( ) ;
61
- f. read_to_end ( & mut d)
54
+ let d = fs:: read_to_string ( "crate-modifications.toml" )
62
55
. expect ( "unable to read crate modifications file" ) ;
63
56
64
57
let modifications: Modifications =
65
- toml:: from_slice ( & d) . expect ( "unable to parse crate modifications file" ) ;
58
+ toml:: from_str ( & d) . expect ( "unable to parse crate modifications file" ) ;
66
59
67
60
let ( dependencies, infos) = rust_playground_top_crates:: generate_info ( & modifications) ;
68
61
@@ -109,7 +102,6 @@ fn main() {
109
102
}
110
103
111
104
fn write_manifest ( manifest : TomlManifest , path : impl AsRef < Path > ) {
112
- let mut f = File :: create ( path) . expect ( "Unable to create Cargo.toml" ) ;
113
- let content = toml:: to_vec ( & manifest) . expect ( "Couldn't serialize TOML" ) ;
114
- f. write_all ( & content) . expect ( "Couldn't write Cargo.toml" ) ;
105
+ let content = toml:: to_string ( & manifest) . expect ( "Couldn't serialize TOML" ) ;
106
+ fs:: write ( path, content) . expect ( "Couldn't write Cargo.toml" ) ;
115
107
}
0 commit comments