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 conditional flattening #1614

Closed
ghost opened this issue Aug 27, 2019 · 1 comment
Closed

Support conditional flattening #1614

ghost opened this issue Aug 27, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 27, 2019

#[derive(Deserialize)]
struct Response<T> {
    #[serde(flatten_if = "Result::is_err")]
    result: Result<T, ResponseErr>,
}
@dtolnay
Copy link
Member

dtolnay commented Jul 5, 2020

I think I would prefer not to build this directly into serde_derive, but it would be reasonable for https://github.com/jonasbb/serde_with or a similar library to provide this functionality.

@dtolnay dtolnay closed this as completed Jul 5, 2020
@serde-rs serde-rs locked and limited conversation to collaborators Jul 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant