Skip to content

Problem with deserializing enums with variants wrapping unit structs #264

@eldyer

Description

@eldyer

I'm trying to deserialize an enum like this:

#[derive(Deserialize)]
struct Unit;

#[derive(Deserialize)]
enum Enum {
    Tuple(u32, u32),
    Struct { x: u32 },
    UnitLike,
    Wrap(Unit),
}

While the first three variants work without problems, I can't find a lua representation for Wrap(Unit):

    let _enum: Vec<Enum> = lua.from_value(
        lua.load(
            r#"
            {
                { Tuple = { 3, 4 } },
                { Struct = { x = 5 } },
                "UnitLike",
                -- "Wrap", -- doesn't work
                -- { Wrap = "Unit" }, -- doesn't work
            }
            "#,
        )
        .eval()?,
    )?;

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