Skip to content

toml_edit: value is not written if table is constructed beforehand #762

Open
@tingerrr

Description

@tingerrr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-editArea: TOML editing APIC-bugCategory: Things not working as expectedM-breaking-changeMeta: Implementing or merging this will introduce a breaking change.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions