Function calamine::deserialize_as_f64_or_none

source ·
pub fn deserialize_as_f64_or_none<'de, D>(
    deserializer: D
) -> Result<Option<f64>, D::Error>
where D: Deserializer<'de>,
Expand description

A helper function to deserialize cell values as f64, useful when cells may also contain invalid values (i.e. strings). It applies the [as_f64] method to the cell value, and returns Ok(Some(value_as_f64)) if successful or Ok(None) if unsuccessful, therefore never failing. This function is intended to be used with Serde’s deserialize_with field attribute.