mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
f9e7b5ffa4
* chore: reload folder * chore: reload folder * chore: init sync * chore: update tables * chore: update database * chore: load row * chore: update * chore: reload row * test: fit test * chore: retry * chore: support batch fetch * chore: enable sync * chore: sync switch * chore: sync switch * chore: migration user data * chore: migrate data * chore: migrate folder * chore: save user email * chore: refresh user profile * chore: fix test * chore: delete translation files * test: clippy format
13 lines
423 B
Rust
13 lines
423 B
Rust
use serde::{Deserialize, Deserializer};
|
|
|
|
/// Handles the case where the value is null. If the value is null, return the default value of the
|
|
/// type. Otherwise, deserialize the value.
|
|
pub(crate) fn deserialize_null_or_default<'de, D, T>(deserializer: D) -> Result<T, D::Error>
|
|
where
|
|
T: Default + Deserialize<'de>,
|
|
D: Deserializer<'de>,
|
|
{
|
|
let opt = Option::deserialize(deserializer)?;
|
|
Ok(opt.unwrap_or_default())
|
|
}
|