-
Notifications
You must be signed in to change notification settings - Fork 72
Use Cow<str> in JSON parsers #545
Copy link
Copy link
Closed
Labels
enhancementAn improvement for livesplit-core.An improvement for livesplit-core.parsingThis is about one of the parsers.This is about one of the parsers.performanceAffects the performance of the code.Affects the performance of the code.suitable for contributionsThe issue is suitable those who are contributing to livesplit-core.The issue is suitable those who are contributing to livesplit-core.
Metadata
Metadata
Assignees
Labels
enhancementAn improvement for livesplit-core.An improvement for livesplit-core.parsingThis is about one of the parsers.This is about one of the parsers.performanceAffects the performance of the code.Affects the performance of the code.suitable for contributionsThe issue is suitable those who are contributing to livesplit-core.The issue is suitable those who are contributing to livesplit-core.
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 useCowto 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)]