MCPcopy Create free account
hub / github.com/aws/aws-lambda-rust-runtime / deserialize_nullish

Function deserialize_nullish

lambda-events/src/custom_serde/mod.rs:67–74  ·  view source on GitHub ↗

Deserializes any `Default` type, mapping JSON `null` to `T::default()`. Note** null-to-empty semantics are usually clear for container types (Map, Vec, etc). For most other data types, prefer modeling fields as ```Option ``` with #[serde(default)] instead of using this deserializer. Option preserves information about the message for the application, and default semantics for the target data typ

(deserializer: D)

Source from the content-addressed store, hash-verified

65/// for the application, and default semantics for the target data type may change
66/// over time without warning.
67pub(crate) fn deserialize_nullish<'de, D, T>(deserializer: D) -> Result<T, D::Error>
68where
69 D: Deserializer<'de>,
70 T: Default + Deserialize<'de>,
71{
72 let opt = Option::deserialize(deserializer)?;
73 Ok(opt.unwrap_or_default())
74}
75
76#[cfg(test)]
77#[allow(deprecated)]

Callers

nothing calls this directly

Calls 1

deserializeFunction · 0.70

Tested by

no test coverage detected