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

This does not work with #[serde(flatten) #18

Closed
vnghia opened this issue Mar 17, 2024 · 1 comment
Closed

This does not work with #[serde(flatten) #18

vnghia opened this issue Mar 17, 2024 · 1 comment

Comments

@vnghia
Copy link

vnghia commented Mar 17, 2024

Hello,

Thank you for your crate. I found one bug here.

#[derive(Deserialize, Debug, PartialEq)]
struct InnerType {
    pub a: Option<u32>,
}

#[derive(Deserialize, Debug, PartialEq)]
struct OuterType {
    #[serde(flatten)]
    pub inner: InnerType,
}

#[test]
fn deserialize_flatten() {
    let params = OuterType { inner: InnerType { a: Some(10) } };
    assert_eq!(super::from_str("a=10"), Ok(params));
}

this code failed with Error("invalid type: string \"10\", expected u32"). It seems that other features do not work as well.

@jplatte
Copy link
Owner

jplatte commented Mar 17, 2024

Hi! I'm afraid this is an instance of serde-rs/serde#1183 and not something this library can fix. My recommendation is to avoid serde(flatten) if you can.

@jplatte jplatte closed this as not planned Won't fix, can't repro, duplicate, stale Mar 17, 2024
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