Skip to content

Untagged enum containing a subtype fails to deserialize, whilst the subtype itself can directly deserialize #1261

Open
@elertan

Description

@elertan

Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9e3bd4da5ac247254d3017e839bd5f39

I have a struct that contains a HashMap<u32, String>.
This type correctly deserializes when using serde_json::from_str() with a json string such as {"data":{"1":"test"}}.

Yet when I put this type into an untagged enum variant, it does not work anymore.
If I then change the key type from u32 to String, it compiles.

This does not seem like intended behaviour, otherwise the variant itself should also fail, see the playground for a better example.

Might be related to:
#1254
#1244

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