pub fn get_optional_parsed<T, F>(
dict: &Bound<'_, PyDict>,
key: &str,
parser: F,
) -> PyResult<Option<T>>
Expand description
Helper function to get an optional value, parse it with a closure, and handle parse errors.
§Returns
Returns Some(parsed_value)
if the key exists and parsing succeeds, None if the key is missing
or if the value is Python None, or a PyErr
if extraction or parsing fails.
§Errors
Returns PyErr
if value extraction or parsing fails (but not if the key is missing or value is None).