Skip to content

feat: unnamed union - #68

Merged
MatrixEditor merged 5 commits into
masterfrom
feat/unnamed-union
Aug 22, 2026
Merged

MatrixEditor merged 5 commits into
masterfrom
feat/unnamed-union

Conversation

@MatrixEditor

@MatrixEditor MatrixEditor commented Aug 22, 2026 •

Copy link
Copy Markdown
Owner

New Feature: Unnamed Unions

This pull request introduces a new Unnamed field (Unnamed[TypeA, TypeB, ...]), a fixed-size, positionally-typed C-union-style field.

@struct
class Packet:
    tag: uint8_t
    payload: Unnamed[uint8_t, uint16_t, uint32_t]

p = unpack(Packet, bytes([0xAB, 0x11, 0x22, 0x33, 0x44]))

assert repr(p.payload) == "Unnamed(?, ?, ?)"
assert p.payload[0] == 0x11   # typing will automatically infer the integer type
assert p.payload._1 == 0x2211
assert p.payload[2] == 0x44332211
assert len(p.payload) == 3

@MatrixEditor
MatrixEditor merged commit 7623d4c into master Aug 22, 2026
13 checks passed
@MatrixEditor
MatrixEditor deleted the feat/unnamed-union branch August 22, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant