Skip to content

Consider requiring explicit indices #17

@robin-nitrokey

Description

@robin-nitrokey

We already learned the hard way that the automatic indexing based on the field order can be a footgun. Skipping fields as implemented in #14 makes it even easier to break compatibility with older versions.

As a workaround, we could require explicit indices (or at least provide an alternative macro that works with explicit indices), for example:

#[derive(Clone, Debug, PartialEq, SerializeIndexed, DeserializeIndexed)]
pub struct SomeKeys {
    #[serde_indexed(index = 1)]
    pub number: i32,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde_indexed(index = 2)]
    pub option: Option<u8>,
    #[serde_indexed(index = 3)]
    pub bytes: [u8; 7],
}

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