Skip to content

Improve Trampoline ergonomics#48

Merged
sivadeilra merged 7 commits intomicrosoft:mainfrom
ranweiler:joranwei/trampoline-fields
Feb 27, 2026
Merged

Improve Trampoline ergonomics#48
sivadeilra merged 7 commits intomicrosoft:mainfrom
ranweiler:joranwei/trampoline-fields

Conversation

@ranweiler
Copy link
Copy Markdown
Contributor

@ranweiler ranweiler commented Feb 25, 2026

This PR offers two changes:

  • Rename the fields of TrampolineFixed for readability and consistency with other symbol structs
  • Add TrampolineFixed methods to view its logical [segment:offset] pairs as OffsetSegment values

The renamed fields constitute a breaking change.

I originally planned on changing the parsing logic of TrampolineFixed to allow direct embedding OffsetSegment values in the struct. But, upon inspection, parsing is nicely trivial if we preserve the actual serialized order of the fields. To retain this simplicity, while also getting the QOL and uniformity of having OffsetSegment values, I just added accessors for users who might want them. By preserving serialized field order in the TrampolineFixed definition, we also retain conventional consistency with other ..Fixed structs.

zerocopy-derive.workspace = true

[dev-dependencies]
hex-literal.workspace = true
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to tear this out and write out a raw slice if you prefer. That said, I've found the macro this crate exports to be very handy for unit testing.

@ranweiler ranweiler force-pushed the joranwei/trampoline-fields branch from 13fedf5 to b087dc6 Compare February 27, 2026 16:00
@sivadeilra sivadeilra merged commit 9266c0d into microsoft:main Feb 27, 2026
3 checks passed
@ranweiler ranweiler deleted the joranwei/trampoline-fields branch February 27, 2026 21:33
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.

2 participants