serde flatten does not work for type in flattened structs that are not strings
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
Using the flatten attribute from serde almost works but breaks in the case of non string values in flattened structs. In this case config always parses size as a string. However, if I put the size attribute directly in Config then everything works.
#[derive(Deserialize)]
struct Config {
#[serde(flatten)]
pub subconfig: Subconfig
}
#[derive(Deserialize)]
struct Subconfig {
pub size: usize
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Config/Subconfig example with serde flatten and a non-string size value, then inspect the config-rs deserialization path. Done means flattened numeric fields such as size: usize parse as numeric values, as they do when declared directly on Config, with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100