Skip to content

validate design with toml #1

Closed
Closed

Description

@erickt
No description provided.

Activity

  1. vhbit commented on Apr 2, 2015

    @vhbit

    any updates on this?

  2. alexcrichton commented on Apr 3, 2015

    @alexcrichton
    Contributor

    I've started a branch of toml-rs to start working on serde support (as an optional feature), but I must admit I'm pretty lost! I basically just copied over all the tests from the rustc_serialize module to ensure that everything works, and I've got a few problems:

    • In JSON terms, I've interpreted missing optional fields as None. For example struct Foo { bar: Option<u32> } can be deserialized from the JSON string {}. It looks like #[derive(Deserialize)], however, will unconditionally emit a missing field error in this case. Would it be possible to tweak the derive-mode?
    • I've also made it such that struct Foo { bar: Vec<u32> } can be deserialized from an empty map (e.g. into an empty Vec for the field bar, which I'm having trouble with for the above reasons.
    • I had to write my own MapVisitor implementation to not require that every map key is used exhaustively. Is this my own error? If not, could that perhaps be an option on the default MapVisitor?

    In general I may just be pretty lost and doing bonkers things in my Deserialize implementation, so any tips would definitely be appreciated!

  3. alexcrichton commented on Apr 21, 2015

    @alexcrichton
    Contributor

    Ok @oli-obk did some awesome work in toml-rs/toml-rs#61 (thanks!). I haven't yet quite grokked it, but there's only a few remaining things that I've turned up:

    • Floats are silently casted to integers. There's a test asserting that this occurrence is a type error, but it passes on serde (fails on rustc-serialize). Probably not the end of the world though!
    • The way enums are deserialized in toml-rs is pretty different from other places. Right now the serializer only supports one piece of payload per variant and then the deserializer for rustc-serialize tries each variant in turn, returning the first one that succeeds. This turns out to be a nice way to encode a field that could have one of multiple forms, and Cargo makes use of this quite heavily. It looks like, however, that the #[derive(Deserialize)] implementation for enums doesn't support this kind of behavior. Right now it expects to learn the variant first and then go forward, but with the current behavior I have it's more of a "let's try something and see if it works"

    TOML is getting close though!

  4. added a commit that references this issue on Jul 15, 2016
  5. added 3 commits that reference this issue on Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions