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
As opposed to Deserializer, Value does not support enum deserialization from inline tables.
Minimal repro steps:
#[derive(Debug,Deserialize,PartialEq)]structMain{test:Test}#[derive(Debug,Deserialize,PartialEq)]structTest{a:A}#[derive(Debug,Deserialize,PartialEq)]enumA{B(String)}fn main(){let tml = r#"[test] a = { B = "test" } "#;let r:Value = toml::from_str(tml).unwrap();let a:Main = r.try_into().unwrap();
Minimal fix would be (excluding the necessary checks from Deserializer):
#[inline]fndeserialize_enum<V>(self,_name:&str,_variants:&'static [&'static str],visitor:V,) -> Result<V::Value,crate::de::Error>whereV: de::Visitor<'de>,{matchself{Value::String(variant) => visitor.visit_enum(variant.into_deserializer()),Value::Table(table) => visitor.visit_enum(MapAccessDeserializer::new(serde::de::value::MapDeserializer::new(table.into_iter()))),// Add this line to support inline tables as well
_ => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,&"string only",)),}}
The text was updated successfully, but these errors were encountered:
epage
changed the title
Value does not support enum deserialization from inline tablesValue does not support enum deserialization from inline tables
Jan 19, 2023
As opposed to Deserializer, Value does not support enum deserialization from inline tables.
Minimal repro steps:
Minimal fix would be (excluding the necessary checks from Deserializer):
The text was updated successfully, but these errors were encountered: