yaml-rust icon indicating copy to clipboard operation
yaml-rust copied to clipboard

About LinkedHashMap

Open KSXGitHub opened this issue 5 years ago • 2 comments

Problem

When I want to create a YAML text from a YAML dictionary, I must first create a Yaml::Hash value. In order to do that, I have to also use linked_hash_map crate. This touching yaml-rust's implementation detail and pray that it does not switch to something else (or having an incompatible version).

Proposals

Do one of the following:

  1. Don't use linked_hash_map::LinkedHashMap directly, instead, create a wrapper type and expose it.

  2. Alternatively, still use linked_hash_map::LinkedHashMap, but also expose it by pub use linked_hash_map. This action requires mininal effort, but this would also mean that yaml-rust's semantic versioning now depends on linked-hash-map as well.


P.S. This issue need a better title. Any suggestion?

KSXGitHub avatar Apr 03 '20 01:04 KSXGitHub

I think (theoretically) it is better to wrap internal map (e.g. LinkedHashMap) with a proxy layer to hide its implementation.

Also make it easier to switch to other map implementation, without breaking map APIs like #157

chyh1990 avatar Jun 02 '20 04:06 chyh1990

@chyh1990 Either way is fine to me. This is a choice for you — the maintainer to make. In my opinion, the first choice would make switching between implementations easier, while the second choice is not a breaking change.

KSXGitHub avatar Jun 02 '20 05:06 KSXGitHub