10 lines
262 B
Rust
10 lines
262 B
Rust
|
use serde::{Deserialize, Deserializer};
|
||
|
|
||
|
pub(crate) fn default_for_null<'de, D, T>(deserializer: D) -> Result<T, D::Error>
|
||
|
where
|
||
|
D: Deserializer<'de>,
|
||
|
T: Deserialize<'de> + Default,
|
||
|
{
|
||
|
Ok(Option::<T>::deserialize(deserializer)?.unwrap_or_default())
|
||
|
}
|