@@ -4,8 +4,7 @@ use rust_playground_top_crates::*;
44use serde:: Serialize ;
55use std:: {
66 collections:: BTreeMap ,
7- fs:: File ,
8- io:: { Read , Write } ,
7+ fs:: { self , File } ,
98 path:: { Path , PathBuf } ,
109} ;
1110
@@ -14,9 +13,7 @@ use std::{
1413struct TomlManifest {
1514 package : TomlPackage ,
1615 profile : Profiles ,
17- #[ serde( serialize_with = "toml::ser::tables_last" ) ]
1816 dependencies : BTreeMap < String , DependencySpec > ,
19- #[ serde( serialize_with = "toml::ser::tables_last" ) ]
2017 build_dependencies : BTreeMap < String , DependencySpec > ,
2118}
2219
@@ -54,15 +51,11 @@ struct Profiles {
5451}
5552
5653fn 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" )
6255 . expect ( "unable to read crate modifications file" ) ;
6356
6457 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" ) ;
6659
6760 let ( dependencies, infos) = rust_playground_top_crates:: generate_info ( & modifications) ;
6861
@@ -109,7 +102,6 @@ fn main() {
109102}
110103
111104fn 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" ) ;
115107}
0 commit comments