8000 #[serde(flatten)] disables treating an integer as a string · Issue #388 · dtolnay/serde-yaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
#[serde(flatten)] disables treating an integer as a string #388
Open
@espindola

Description

@espindola

In the following example the first struct deserializes , but the second one fails with "invalid type: integer 42, expected a string".

use serde::Deserialize;

#[derive(Deserialize)]
struct Inner {
    x: String,
}

#[derive(Deserialize)]
struct S {
    #[serde(flatten)]
    inner: Inner,
}

fn main() {
    let t = "x: 42";
    let v: Inner = serde_yaml::from_str(t).unwrap();
    println!("{}", v.x);

    let v: S = serde_yaml::from_str(t).unwrap();
    println!("{}", v.inner.x);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0