Skip to content

ENH: Add as_res_f64 etc, analogous to as_opt_f64 but containing full error information in Err variant #6

Description

@corneliusroemer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions