Skip to main content

empty_string_as_none

Function empty_string_as_none 

Source
pub(crate) fn empty_string_as_none<'de, D, T>(
    deserializer: D,
) -> Result<Option<T>, D::Error>
where D: Deserializer<'de>, T: FromStr + Deserialize<'de>, T::Err: Display,
Expand description

Helper for serde: deserializes missing values and empty form strings as None. Lets the same struct be used for JSON payloads and HTMX form submissions where numeric inputs may be left blank.