pub fn get_optional<T>(
dict: &Bound<'_, PyDict>,
key: &str,
) -> PyResult<Option<T>>where
T: for<'a, 'py> FromPyObject<'a, 'py>,
for<'a, 'py> PyErr: From<<T as FromPyObject<'a, 'py>>::Error>,Expand description
Helper function to get an optional value from a Python dictionary.
§Returns
Returns Some(value) if the key exists and extraction succeeds, None if the key is missing
or if the value is Python None, or a PyErr if extraction fails.
§Errors
Returns PyErr if value extraction fails (but not if the key is missing or value is None).