Skip to content

Commit cf7762f

Browse files
authored
Merge pull request #2774 from ehuss/update-toml
Update toml to 0.9.2
2 parents f8e66db + 26319f4 commit cf7762f

File tree

4 files changed

+78
-13
lines changed

4 files changed

+78
-13
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ shlex = "1.3.0"
5959
snapbox = "0.6.21"
6060
tempfile = "3.20.0"
6161
tokio = "1.46.1"
62-
toml = "0.5.11" # Do not update, see https://github.com/rust-lang/mdBook/issues/2037
62+
toml = "0.9.2"
6363
topological-sort = "0.2.2"
6464
tower-http = "0.6.6"
6565
walkdir = "2.5.0"

crates/mdbook-core/src/utils/toml_ext.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ fn split(key: &str) -> Option<(&str, &str)> {
6262
#[cfg(test)]
6363
mod tests {
6464
use super::*;
65-
use std::str::FromStr;
6665

6766
#[test]
6867
fn read_simple_table() {
6968
let src = "[table]";
70-
let value = Value::from_str(src).unwrap();
69+
let value: Value = toml::from_str(src).unwrap();
7170

7271
let got = value.read("table").unwrap();
7372

@@ -77,7 +76,7 @@ mod tests {
7776
#[test]
7877
fn read_nested_item() {
7978
let src = "[table]\nnested=true";
80-
let value = Value::from_str(src).unwrap();
79+
let value: Value = toml::from_str(src).unwrap();
8180

8281
let got = value.read("table.nested").unwrap();
8382

@@ -108,7 +107,7 @@ mod tests {
108107
#[test]
109108
fn delete_a_top_level_item() {
110109
let src = "top = true";
111-
let mut value = Value::from_str(src).unwrap();
110+
let mut value: Value = toml::from_str(src).unwrap();
112111

113112
let got = value.delete("top").unwrap();
114113

@@ -118,7 +117,7 @@ mod tests {
118117
#[test]
119118
fn delete_a_nested_item() {
120119
let src = "[table]\n nested = true";
121-
let mut value = Value::from_str(src).unwrap();
120+
let mut value: Value = toml::from_str(src).unwrap();
122121

123122
let got = value.delete("table.nested").unwrap();
124123

crates/mdbook-driver/src/init.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ impl BookBuilder {
101101
fn write_book_toml(&self) -> Result<()> {
102102
debug!("Writing book.toml");
103103
let book_toml = self.root.join("book.toml");
104-
let cfg = toml::to_vec(&self.config).with_context(|| "Unable to serialize the config")?;
104+
let cfg =
105+
toml::to_string(&self.config).with_context(|| "Unable to serialize the config")?;
105106

106-
File::create(book_toml)
107-
.with_context(|| "Couldn't create book.toml")?
108-
.write_all(&cfg)
109-
.with_context(|| "Unable to write config to book.toml")?;
107+
std::fs::write(&book_toml, cfg)
108+
.with_context(|| format!("Unable to write config to {book_toml:?}"))?;
110109
Ok(())
111110
}
112111

0 commit comments

Comments
 (0)