Skip to content

with_prefix attribute #759

@xamgore

Description

@xamgore

Hi, I am wondering, is it technically possible to omit separate macro-calls (as in #9) and inline them into the list of attributes?

#[derive(Serialize, Deserialize)]
struct Match {
    #[serde(flatten, with_prefix = "player1_")]
    player1: Player,
    #[serde(flatten, with_prefix = "player2_")]
    player2: Player,
}

#[derive(Serialize, Deserialize)]
struct Player {
    name: String,
    votes: u64,
}

I'm in the middle of writing a docx-template library, that takes user data and distributes it to a document's {placeholders}. Things get worse, when you have a lot of keys, so flatten+with_prefix would allow avoiding name conflicts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions