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
Quoting the documentation for #[serde(skip_deserializing)]: When deserializing, Serde will useDefault::default()or the function given bydefault = "..."to get a default value for this field.
Option<T> defaults to None event if T doesn't implement Default, so why does the compiler complain T must implement such Default trait for me to be able to derive Deserialize?
Sample code (uncomment /* Default */ to have the code compile):
Oddly enough, I noticed that in my case, manually specifying the default function to Default::default() makes the code compile without restraining T to implement Default:
Quoting the documentation for
#[serde(skip_deserializing)]
:When deserializing, Serde will use
Default::default()
or the function given bydefault = "..."
to get a default value for this field.Option<T>
defaults toNone
event ifT
doesn't implementDefault
, so why does the compiler complainT
must implement suchDefault
trait for me to be able to deriveDeserialize
?Sample code (uncomment
/* Default */
to have the code compile):Same code in Rust playground
The text was updated successfully, but these errors were encountered: