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

Nested struct #15

Closed
xoac opened this issue Aug 23, 2018 · 4 comments
Closed

Nested struct #15

xoac opened this issue Aug 23, 2018 · 4 comments

Comments

@xoac
Copy link

xoac commented Aug 23, 2018

#[derive(Deserialize, Debug)]
struct A {
  u: i32,
  y: String,
}
#[derive(Deserialize, Debug)]
struct B {
 a: A,
}

Is possible to de-serialize above? I would expected to work this as A_U=5 A_Y="Test" or A=U=5,y=Test but it don't.

@softprops
Copy link
Owner

This is interesting but potentially might actually call for storing this configuration in medium that supports representing more complex structures like yaml/json/ect.

envy if focused a more on flat key => value ( env style ) configuration. it seems like you may be wanting keya => keyb => keyc => value. Which is totally fine but not typically the kind format that envy is focused on.

That said, I would be open to a pr for this if you're up for it if you have an idea of what you'd be looking for.

@xoac
Copy link
Author

xoac commented Aug 31, 2018

What I want it can be easy done with #serde(flatten). So you can close issue if u dont want support nested structures ;)

@softprops
Copy link
Owner

I'm happy to take prs but it seems you've found a pathway. Thanks for reaching out. I'll take a look at the flatten attr

@softprops
Copy link
Owner

Dropping a note here for now for future folks that fall apon this issue https://serde.rs/attr-flatten.html

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

No branches or pull requests

2 participants