Repository navigation
describe a tuple struct's rest from its element type - #55
Merged
Merged
Conversation
A tuple struct's rest is a sequence of one element type: it is spliced into the tuple's array one element at a time, and one additionalItems schema describes every element past the fixed fields. The schema spelled it out as the rest's own schema, which is right only for a std Vec; #39 fixed that one case by name. The walk behind array_bounds now answers with the rest's elements (ArrayElements: an element type with its count, or an unknown type in a count the walk may know), and both the bounds and the schema come from it. The element of a Vec, Set, or fixed array becomes additionalItems when it has a schema, through any alias, newtype, or Box. A tuple or a tuple struct counts when its elements all have one type, since which of those forms the input took is the input's business. A native type, a cycle, a unit struct whose constant is an array (values, not types), or an element without a schema inside a container that has one leave additionalItems true rather than wrong, matching what the bounds already did for an unknown count. A rest that is none of these (a tuple or tuple struct of mixed types, a unit struct with a scalar constant, a struct, a scalar) used to render a wrong schema and fail at serialization time; finalize now rejects it as Error::InvalidRest. The tests live in render.rs with the rest of the tuple struct tests; the separate file and fixtures from #39 are folded in. The fixed array, tuple, and newtype rests round-trip through json-serde's flattening helpers, which 1.0 limits to a serde seq: json-serde is patched to the merged oxidecomputer/json-serde#11 until 1.1.0 ships.
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.
No description provided.