Skip to content

Trouble with non-existing fields #299

Closed
@f-saez

Description

@f-saez

Hi,

fn main() {
    let toml = r#"[package]
    name = "test"
    version = "0.1.0"
    edition = "2021"
     "#;

    let doc = toml.parse::<Document>().expect("invalid doc");
    dbg!(&doc["package"]["resolver"].is_none());
}

This code panic with message 'index not found', meaning it panic before evaluating is_none()

Same code worked well with toml_edit = "0.6.0" :

[src/main.rs:12] &doc["package"]["resolver"].is_none() = true

It stopped working with 0.7 to 0.12.6

If it's not a bug, how can I easily test if a field exists ?

thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-questionUncertainty is involved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions