Move extension type construction logic out of Field #9266
+53
−28
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.
Which issue does this PR close?
Rationale for this change
The logic to instantiate a type extension does not really depend on
Field, other than indirectly because that struct happens to contain all the necessary bits of information.As part of the work to make the JSON decoder support extension types, it was observed that a field is not always available (or at least, not desirable because it creates redundancy). This change addresses the concern by making it possible to work directly with extension types instead of being forced to route through a
Fieldinstance.What changes are included in this PR?
Factor out the body of
Field::try_extension_typeas a new associated functionExtensionType::try_new_from_field_metadatathat takes data type and field metadata map and delegates toExtensionType::try_new.Field::try_extension_typethen simply calls that new method.Are these changes tested?
Code movement. Existing unit tests validate it.
Are there any user-facing changes?
New provided trait method.