{"action":"created","issue":{"url":"https://api.github.com/repos/arcnmx/serde-ini/issues/6","repository_url":"https://api.github.com/repos/arcnmx/serde-ini","labels_url":"https://api.github.com/repos/arcnmx/serde-ini/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/arcnmx/serde-ini/issues/6/comments","events_url":"https://api.github.com/repos/arcnmx/serde-ini/issues/6/events","html_url":"https://github.com/arcnmx/serde-ini/issues/6","id":378479202,"node_id":"MDU6SXNzdWUzNzg0NzkyMDI=","number":6,"title":"auto convert problem with serde `flatten`","user":{"login":"Larusso","id":2523575,"node_id":"MDQ6VXNlcjI1MjM1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/2523575?v=4","gravatar_id":"","url":"https://api.github.com/users/Larusso","html_url":"https://github.com/Larusso","followers_url":"https://api.github.com/users/Larusso/followers","following_url":"https://api.github.com/users/Larusso/following{/other_user}","gists_url":"https://api.github.com/users/Larusso/gists{/gist_id}","starred_url":"https://api.github.com/users/Larusso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Larusso/subscriptions","organizations_url":"https://api.github.com/users/Larusso/orgs","repos_url":"https://api.github.com/users/Larusso/repos","events_url":"https://api.github.com/users/Larusso/events{/privacy}","received_events_url":"https://api.github.com/users/Larusso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-07T21:36:03Z","updated_at":"2018-11-08T08:44:05Z","closed_at":null,"author_association":"NONE","body":"https://github.com/Larusso/serde-ini-fail-example/blob/master/src/lib.rs\r\n\r\nThis example is derived from some experimentation I do at the moment.\r\nIt creates three different struct layouts and tries to deserialize the same test data into it.\r\n\r\nIf you run the tests you will see that the test `data_3` (which deserilized into `Data3` struct) fails because of the number deserialization issue.  \r\n\r\nFor a better visibility here are the three structs:\r\n```rust\r\n#[derive(Deserialize, Debug)]\r\n#[serde(rename_all = \"PascalCase\")]\r\npub struct Data {\r\n    #[serde(default, skip_serializing_if = \"Option::is_none\")]\r\n    section_1: Option<Box<FieldData>>,\r\n    #[serde(default, skip_serializing_if = \"Option::is_none\")]\r\n    section_2: Option<Box<FieldData>>,\r\n    #[serde(default, skip_serializing_if = \"Option::is_none\")]\r\n    section_3: Option<Box<FieldData>>,\r\n}\r\n\r\n#[derive(Deserialize, Debug)]\r\n#[serde(transparent)]\r\npub struct Data2(HashMap<Keys,FieldData>);\r\n\r\n#[derive(Deserialize, Debug)]\r\n#[serde(rename_all = \"PascalCase\")]\r\npub struct Data3 {\r\n    section_1: FieldData,\r\n\r\n    #[serde(flatten)]\r\n    components: HashMap<Keys, FieldData>,\r\n}\r\n```\r\n\r\nAll three tests in this sample setup use the same struct: `FieldData` for the fields and the deserializer has no issues with it in the `data_1` and `data_2` tests.\r\n\r\nI hope this helps you\r\n\r\n_Originally posted by @Larusso in https://github.com/arcnmx/serde-ini/issues/5#issuecomment-436680993_"},"comment":{"url":"https://api.github.com/repos/arcnmx/serde-ini/issues/comments/436916458","html_url":"https://github.com/arcnmx/serde-ini/issues/6#issuecomment-436916458","issue_url":"https://api.github.com/repos/arcnmx/serde-ini/issues/6","id":436916458,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjkxNjQ1OA==","user":{"login":"dtolnay","id":1940490,"node_id":"MDQ6VXNlcjE5NDA0OTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1940490?v=4","gravatar_id":"","url":"https://api.github.com/users/dtolnay","html_url":"https://github.com/dtolnay","followers_url":"https://api.github.com/users/dtolnay/followers","following_url":"https://api.github.com/users/dtolnay/following{/other_user}","gists_url":"https://api.github.com/users/dtolnay/gists{/gist_id}","starred_url":"https://api.github.com/users/dtolnay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtolnay/subscriptions","organizations_url":"https://api.github.com/users/dtolnay/orgs","repos_url":"https://api.github.com/users/dtolnay/repos","events_url":"https://api.github.com/users/dtolnay/events{/privacy}","received_events_url":"https://api.github.com/users/dtolnay/received_events","type":"User","site_admin":false},"created_at":"2018-11-08T08:44:05Z","updated_at":"2018-11-08T08:44:05Z","author_association":"NONE","body":"This is the same underlying limitation as https://github.com/serde-rs/serde/issues/1183 and https://github.com/serde-rs/json/issues/497. We will be able to handle this better in Serde once associated type defaults are available (https://github.com/rust-lang/rust/issues/29661).\r\n\r\nFor now I would recommend keeping the type conversions in serde_ini but using a `#[serde(with = \"...\")]` attribute on non-string fields that get flattened, in this case `size`. The implementation in [`serde_with::rust::display_fromstr`](https://docs.rs/serde_with/0.2.2/serde_with/rust/display_fromstr/index.html) should do the trick."}}
{"actor":{"display_login":"dtolnay"}}