LiveSplit / livesplit-core

livesplit-core is a library that provides a lot of functionality for creating a speedrun timer.

Home Page:https://livesplit.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `Cow<str>` in JSON parsers

CryZe opened this issue · comments

It was under the impression that you can't borrow with serde_json, but it's totally possible. The API directly supports it. The only thing you need to be careful about are escaped strings, but for those you can just use Cow to handle the owned unescaped case. Apparently there's an annotation you need to use though to specify that you prefer a borrowed str if possible on such a container. Each such field needs to be annotated with #[serde(borrow)]