Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deserializing dotted table with an enum value #388

Closed
spikegrobstein opened this issue Dec 10, 2022 · 0 comments · Fixed by #462
Closed

Error when deserializing dotted table with an enum value #388

spikegrobstein opened this issue Dec 10, 2022 · 0 comments · Fixed by #462
Labels
A-serde Area: Serde integration C-bug Category: Things not working as expected

Comments

@spikegrobstein
Copy link

When deserializing a value represented as an enum, I receive an error if I use a dotted table, but it parses fine if I use an inline table:

ErrorInner { kind: Wanted { expected: "string or inline table", found: "dotted table" } ...

minimal example code:

use serde::Deserialize;

#[derive(Deserialize)]
struct DataFile {
    data: Compare,
}

#[derive(Deserialize)]
enum Compare {
    Gt(u32),
}

fn main() {
    let dotted_table = r#"
        data.Gt = 5
        "#;

    let inline_table = r#"
        data = { Gt = 5 }
        "#;

    // I wouldn't expect this to error
    assert!(toml::from_str::<DataFile>(dotted_table).is_err());

    // this one is ok, though.
    assert!(toml::from_str::<DataFile>(inline_table).is_ok());
}
epage added a commit to epage/toml_edit that referenced this issue Jan 18, 2023
@epage epage added C-bug Category: Things not working as expected A-serde Area: Serde integration labels Jan 18, 2023
epage added a commit that referenced this issue Jan 18, 2023
test(serde): Verify #388 was fixed by #457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-serde Area: Serde integration C-bug Category: Things not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants