Make wast parse results serializable #1432
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1428 by liberally sprinkling
derive(Serialize, Deserialize)
and friends on things until it built.Concurrently with making this PR, I found a different approach for the high-level thing I wanted this for, and therefore don't have any immediate use for it. If you therefore don't think it's worth the hit to code readability, feel free to close without reading further. I figured I'd submit it anyway since I was halfway done at that point.
Some notes:
#[serde(borrow)]
needs to go on at least one field of a structure or variant of enum which uses a lifetime parameter, but it suffices to put it on any one of them in the case that there are multiple. I put it on only the first but could do something else if you want.tag = "type", content = "val"
on all the enums.CoreItemRef
- are generic and have a field whose type is given by the generic. That perforce means that the generic type needs to be constrained to be serializable as well, but only when the feature is enabled. I've done this, but it's a bit ugly, and if you have a better approach to suggest I'd happily take it: