Skip to content

describe a tuple struct's rest from its element type - #55

Merged
ahl merged 2 commits into
mainfrom
tuple-remainder-schema
Nov 16, 2026
Merged

ahl merged 2 commits into
mainfrom
tuple-remainder-schema

Conversation

@ahl

@ahl ahl commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

ahl added 2 commits November 15, 2026 22:49
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.
@ahl
ahl merged commit 3f74eb7 into main Nov 16, 2026
10 checks passed
@ahl
ahl deleted the tuple-remainder-schema branch November 16, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant