Skip to content

Commit d257da0

Browse files
committed
Update top-crates to toml 0.7
1 parent 6ff7fb5 commit d257da0

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

top-crates/Cargo.lock

Lines changed: 47 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

top-crates/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ semver = { version = "1.0.11", features = ["serde"] }
1616
serde = "1.0.1"
1717
serde_derive = "1.0.1"
1818
serde_json = "1.0.0"
19-
toml = "0.5.0"
19+
toml = "0.7.0"

top-crates/src/main.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use rust_playground_top_crates::*;
44
use serde::Serialize;
55
use 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::{
1413
struct 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

5653
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")
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

111104
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");
115107
}

0 commit comments

Comments
 (0)