toml icon indicating copy to clipboard operation
toml copied to clipboard

`toml_edit`: value is not written if table is constructed beforehand

Open tingerrr opened this issue 6 months ago • 5 comments

The following code simply discards the last write to the tests sub-key.

use toml_edit::{DocumentMut, value};

fn main() {
    let toml = "";
    let mut doc = toml.parse::<DocumentMut>().expect("invalid doc");
    // doc["tool"] = toml_edit::table();
    // doc["tool"]["typst-test"] = toml_edit::table();
    doc["tool"]["typst-test"]["tests"] = value("tests");
    println!("doc: \n{}\n", doc.to_string());
}

Produces the following output:

tool = { typst-test = { tests = "tests" } }

Uncommenting the second line produces:

tool = {}

Uncommenting the second and first line produces:

[tool]

[tool.typst-test]
tests = "tests"

When inspecting the table tool.typst-test, the value exists, it's simply not written.

tingerrr avatar Jul 28 '24 13:07 tingerrr