You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working off of the master branch at commit 7466647 attempting to take advantage of the ability to parse maps into structs so that I can use #[serde(flatten)]. It almost works, but I get a strange parsing error during a roundtrip for a particular structure. Here's a minimal reproducible example:
use serde::{Serialize,Deserialize};use ron::ser::*;fnmain(){let data = Outer{inner:Inner{new_type:NewType(vec![])},};let serialized = to_string_pretty(&data,PrettyConfig::default()).unwrap();println!("{serialized}");let deserialized:Outer = ron::from_str(&serialized).unwrap();}#[derive(Serialize,Deserialize)]structOuter{#[serde(flatten)]// Without this attribute, everything worksinner:Inner,}#[derive(Serialize,Deserialize)]structInner{new_type:NewType,}#[derive(Serialize,Deserialize)]// #[serde(transparent)] // With this attribute, everything worksstructNewType(Vec<u32>);
The error I get is
SpannedError { code: InvalidValueForType { expected: "u32", found: "a sequence" }, position: Position { line: 3, col: 1 } }
Strangely if I add #[serde(transparent)] to NewType or if I remove #[serde(flatten)] from Outer then everything works. In my specific case, I definitely don't mind using #[serde(transparent)], but it seems like the error is probably a bug that's worth addressing.
The text was updated successfully, but these errors were encountered:
I'm working off of the master branch at commit 7466647 attempting to take advantage of the ability to parse maps into structs so that I can use
#[serde(flatten)]
. It almost works, but I get a strange parsing error during a roundtrip for a particular structure. Here's a minimal reproducible example:The error I get is
Strangely if I add
#[serde(transparent)]
toNewType
or if I remove#[serde(flatten)]
fromOuter
then everything works. In my specific case, I definitely don't mind using#[serde(transparent)]
, but it seems like the error is probably a bug that's worth addressing.The text was updated successfully, but these errors were encountered: