chipsenkbeil / vimwiki-rs

Rust library and tooling to parse, render, and modify vimwiki text and files.
56 stars 2 forks source link

Write tests to validate that all of vimwiki elements can be converted to json #123

Open chipsenkbeil opened 3 years ago

chipsenkbeil commented 3 years ago

We want to make sure that json conversions work. While this could be worked around by using another format, it would be good to support this and it's really easy.

The issue was that I had HashMap<SomeStruct, ...> where SomeStruct was hashable, but that can't be used by serde_json. There was supposedly support for using Display and FromStr, but the FromStr doesn't appear to get used by serde. Maybe there is a way to use it in that way, but the better approach is to use

struct BiggerStruct {
    #[serde(with = "serde_with::rust::map_as_tuple_list")]
    map: HashMap<SomeStruct, OtherData>,
}