Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unrolling arrays #2799

Open
feliwir opened this issue Aug 13, 2024 · 0 comments
Open

Support unrolling arrays #2799

feliwir opened this issue Aug 13, 2024 · 0 comments

Comments

@feliwir
Copy link

feliwir commented Aug 13, 2024

Hey, I got a struct like this (small sample):

#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(default, deny_unknown_fields, rename_all = "PascalCase")]
pub struct GlobalData {
    pub vertex_water_available_maps: [String; 4],
}

Which is serialized like this:

GameData
  VertexWaterAvailableMaps1 = "sample"
  VertexWaterAvailableMaps2 = "sample"
  VertexWaterAvailableMaps3 = "sample"
  VertexWaterAvailableMaps4 = "sample"
End

I'd love support a field attribute #[serde(unroll)].
Optional:

  • Specify the start index (e.g. 0/1 or 'A'/'B')
  • Specify the suffix type (numerical or alpha)

I know this is not a trivial feature, but I got literally hundreds of arrays like these. Unrolling them manually makes them less accessible and code a lot harder to read.

The complete format I'm currently deserializing can be seen here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant