Skip to content

Exposing Number Kind #366

Open
Open
@VictorKoenders

Description

@VictorKoenders

I have been working on a json-to-struct generator for a project, and I ran into an issue that I did not actually know the type of number. It would be useful to expose the type of the Number.

For reference: https://github.com/serde-rs/json/blob/master/src/number.rs#L17-L32

After discussion with @oli-obk we came to the following possibilities:

  1. Making Number::n and N pub
    https://play.rust-lang.org/?gist=76af67ced7d5a9ff3aad1d0a10878b46&version=stable
  2. Introducing a NumberKind type and implementing a kind() function on Number
    https://play.rust-lang.org/?gist=017cb7efe26cd6bf9a2b6b35f0f76dce&version=stable
  3. Merging N into Number, making Number the enum itself
    https://play.rust-lang.org/?gist=ee1d87a959c1e3d8da982418222b65ac&version=stable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions