Code Monkey home page Code Monkey logo

Comments (4)

dtolnay avatar dtolnay commented on May 27, 2024

Can you give a bit more detail on how you are using LinkedHashMap in your project? In particular, what is stopping you from upgrading your own linked-hash-map dependency to 0.4 without worrying about what serde_yaml uses?

from serde-yaml.

CmdrMoozy avatar CmdrMoozy commented on May 27, 2024

I forked your repository and added a branch with a simple reproduction / example: https://github.com/CmdrMoozy/serde-yaml/tree/issue_46.

The problem is that I want to deserialize a YAML structure which contains some sub-structure that is opaque to me (both its contents and structure vary wildly), so I want to have a serde_yaml::Mapping member of the struct I deserialize into.

However, serde_yaml's dependency on linked_hash_map doesn't enable its serde support, and version 0.3 of linked_hash_map is depending on serde 0.8, so we need to both bump the version and enable the serde_impl feature to get LinkedHashMap to implement Serialize, Deserialize for the right version of serde.

from serde-yaml.

dtolnay avatar dtolnay commented on May 27, 2024

Rather than bumping the dependency and relying on their Serde impls, I would prefer to go in the direction that serde_json has taken with serde_json::Map which is an opaque wrapper around an underlying map type. So in our case we would have:

pub struct Mapping {
    map: LinkedHashMap<Value, Value>,
}

impl Mapping { /* ... */ }
impl Default, Clone, PartialEq, Index, IndexMut, Debug, Extend,
    FromIterator, IntoIterator, Serialize, Deserialize for Mapping { /* ... */ }

This way we avoid tying the serde_yaml public API to a particular version of linked-hash-map and we can swap out the underlying implementation transparently when linked-hash-map makes breaking changes or is superseded by a different library.

Would you be able to submit a PR for this change?

from serde-yaml.

CmdrMoozy avatar CmdrMoozy commented on May 27, 2024

Sure, I'll send a PR later today.

from serde-yaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.