Skip to content

Feature: Allow to skip seq access for internally and adjacently tagged enums #2932

@Dzordzu

Description

@Dzordzu

Both the adjacently tagged and internally tagged representations can be
expressed either via map or sequence syntax. For example:

#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", content = "x")]
enum MyType {
    Topic(i64), Sidebar(i64)
}

fn main() {}

is equivalent to both (sequence syntax)

[ "Topic", 1 ]

and (map syntax)

{ "type": "Topic", "x": 1 }

Disable the sequence format

In case you want to disable the sequence format, you can use the
#[serde(seq=false)].

#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", content = "x", seq_form=false)]
enum MyType {
    Topic(i64), Sidebar(i64)
}

will casue the sequence syntax to be disabled.

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