pub fn deserialize<'de, D, T>(deserializer: D) -> Result<T, D::Error>
    where
        D: Deserializer<'de>,
        T: Deserialize<'de> + Default,
    {
        #[derive(Debug, serde::Deserialize)]
        #[serde(untagged)]
        enum GoodOrError<T> {
            Good(T),
            // This consumes one "item" when `T` errors while deserializing.
            // This is necessary to make this work, when instead of having a direct value
            // like integer or string, the deserializer sees a list or map.
            Error(serde::de::IgnoredAny),
        }

        Ok(match Deserialize::deserialize(deserializer) {
            Ok(GoodOrError::Good(res)) => res,
            _ => Default::default(),
        })
    }
/// Deserialize T and return the [`Default`] value on error
Deserialize T and return the [`Default`] value on error
Deserialize T and return the [ ` Default ` ] value on error
pub fn deserialize<'de, D, T>(deserializer: D) -> Result<T, D::Error>
    where
        D: Deserializer<'de>,
        T: Deserialize<'de> + Default,
    {
        #[derive(Debug, serde::Deserialize)]
        #[serde(untagged)]
        enum GoodOrError<T> {
            Good(T),
            // This consumes one "item" when `T` errors while deserializing.
            // This is necessary to make this work, when instead of having a direct value
            // like integer or string, the deserializer sees a list or map.
            Error(serde::de::IgnoredAny),
        }
        Ok(match Deserialize::deserialize(deserializer) {
            Ok(GoodOrError::Good(res)) => res,
            _ => Default::default(),
        })
    }
pub fn deserialize < ' de , D , T > ( deserializer : D ) -> Result < T , D :: Error > where D : Deserializer < ' de > , T : Deserialize < ' de > + Default , { # [ derive ( Debug serde Deserialize ) ] # [ serde ( untagged ) ] enum GoodOrError < T > { Good ( T ) , // This consumes one "item" when `T` errors while deserializing. // This is necessary to make this work, when instead of having a direct value // like integer or string, the deserializer sees a list or map. Error ( serde :: de :: IgnoredAny ) , } Ok ( match Deserialize :: deserialize ( deserializer ) { Ok ( GoodOrError :: Good ( res ) ) => res , _ => Default :: default ( ) , } ) }
Deserialize T and return the [`Default`] value on error
Deserialize T and return the [ ` Default ` ] value on error
deserializer
D
deserializer
D