Add Clone implementation for Parser and Scanner#91
Open
fasterthanlime wants to merge 2 commits intosaphyr-rs:masterfrom
Open
Add Clone implementation for Parser and Scanner#91fasterthanlime wants to merge 2 commits intosaphyr-rs:masterfrom
fasterthanlime wants to merge 2 commits intosaphyr-rs:masterfrom
Conversation
This enables use cases like deserializing flattened structs where you need to scan ahead to determine field mappings, then rewind to deserialize in a different order. The implementation is conditional on T: Clone, so it doesn't affect users who don't need this capability. Changes: - BufferedInput<T>: derive Clone - StrInput<'a>: derive Clone, Copy - Scanner<'input, T>: impl Clone where T: Input + Clone - Parser<'input, T>: impl Clone where T: Input + Clone - ImplicitMappingState: derive Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For a deserialization use case, it's useful for us at https://github.com/facet-rs/facet to kind of peek, not just by one event, by as many events as it takes to disambiguate things like flatten and untagged annotations on enums and structs. But it is very much look ahead and we throw away that information once we've disambiguated.
And then we would like to keep using the parser we had in the first place, the real one. So that's why I would like support to clone all the internals of the parser, which I believe should be relatively cheap, especially if the input is a slice and hopefully should not be a big maintenance burden for you?
I don't mind using a fork for a while, but I believe this is like the most promising event-based parser for YAML. And it would be nice to be on upstream :)