Deduplicate similar methods of ContentDeserializer and ContentRefDeserializer#2557
Closed
Mingun wants to merge 2 commits into
Closed
Deduplicate similar methods of ContentDeserializer and ContentRefDeserializer#2557Mingun wants to merge 2 commits into
ContentDeserializer and ContentRefDeserializer#2557Mingun wants to merge 2 commits into
Conversation
dtolnay
requested changes
Aug 7, 2023
dtolnay
left a comment
Member
There was a problem hiding this comment.
Thank you!
This looks good except for the "Merge unexpected() into invalid_type()" commit. I think those are intentionally separate. unexpected is a relatively big chunk of logic that shouldn't need to be re-instantiated downstream for all the different E types that Content is used with. It is supposed to be instantiated once in the serde crate.
…eserializer Thus we can guarantee that the implementation the same for both deserializers
thus we can be sure that all integers also would be handled when floats are requested
f748ca8 to
c2b0bc7
Compare
Contributor
Author
|
Makes sense. I removed this commit |
Contributor
Author
|
The correct way is completely remove any attempt to return error from the deserializer itself. Closed in preference to #2569 |
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.
This PR moves helper functions that is implemented identically in both content deserializers to the
Contentitself, which would guarantee that they are always have the same implementation.The last commit also express
deserialize_floatmethod in terms ofdeserialize_integermethod. While that is good for readability, maybe compiler will not inline it and it can be slightly slower. If you do not like it, you can drop the last commit from that PR