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
When serializing a struct containing Option with a custom serializer, we get an UnsupportedType(None) error.
Note that this work as expected using toml < 0.5 and panic starting from 0.6.
Here is a minimal reproducer:
use std::fmt;use std::fmt::Formatter;use serde::{Serialize,Serializer};structPerson{name:String,age:Option<u16>}implSerializeforPerson{fnserialize<S>(&self,serializer:S) -> Result<S::Ok,S::Error>whereS:Serializer,{
serializer.serialize_str(&self.to_string())}}impl fmt::DisplayforPerson{fnfmt(&self,f:&mutFormatter<'_>) -> fmt::Result{write!(f,"{}",self.name)}}fnmain(){// Panics on toml = ^0.6// Works with toml = 0.5
toml::to_string(&Person{name:"tom".to_string(),age:None,}).unwrap();}
The text was updated successfully, but these errors were encountered:
This is serializing a string as a top-level TOML document which is invalid TOML syntax. If you want to deserialize a TOML value, you can use ValueSerailizer. As this is working as expected, I'm closing this, If there is a reason for us to re-evaluate this, let us know!
Seems related to #603, #636
When serializing a struct containing
Option
with a custom serializer, we get anUnsupportedType(None)
error.Note that this work as expected using toml < 0.5 and panic starting from 0.6.
Here is a minimal reproducer:
The text was updated successfully, but these errors were encountered: