Description
Both the as_f64 and as_opt_f64 (see #5) functions throw away information:
as_f64 either coerces silently or errors the entire deserialization operation.
as_opt_f64 errors less, but contains no information on what went wrong when something goes wrong, as None has no inner value
It would make sense to add another function type as_res_f64, that keeps the error information around, so the downstream user can report and handle edge cases as desired.
The deserialization would then return `Res<f64, serde_this_or_that::Err>. The Error variant could contain:
- The original value passed to
as_res_f64, e.g. String("null") or bool::True etc.
- Information on what failed, e.g. "bool cannot be coerced to f64"
There could also be different error kinds, so that users could handle them differently.
Before starting the implementation, it would probably be a good idea to work out the full behaviour matrix for various inputs
Description
Both the
as_f64andas_opt_f64(see #5) functions throw away information:as_f64either coerces silently or errors the entire deserialization operation.as_opt_f64errors less, but contains no information on what went wrong when something goes wrong, asNonehas no inner valueIt would make sense to add another function type
as_res_f64, that keeps the error information around, so the downstream user can report and handle edge cases as desired.The deserialization would then return `Res<f64, serde_this_or_that::Err>. The Error variant could contain:
as_res_f64, e.g.String("null")orbool::Trueetc.There could also be different error kinds, so that users could handle them differently.
Before starting the implementation, it would probably be a good idea to work out the full behaviour matrix for various inputs