Skip to content

Format drops comments between items in a table #818

@charliermarsh

Description

@charliermarsh

Below, # one and # two are dropped by calling .fmt():

use toml_edit::DocumentMut;

fn main() {
    let toml = r#"
[items]
# one
foo = [1, 2, 3]
# two
bar = [4, 5, 6]
    "#;
    let mut doc = toml.parse::<DocumentMut>().expect("invalid doc");
    doc["items"].as_table_mut().map(|t| t.fmt());
    let expected = r#"
[items]
foo = [1, 2, 3]
bar = [4, 5, 6]
    "#;
    assert_eq!(doc.to_string(), expected);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions