Repository navigation
Changelog, API docs, enum type inference and Bits<N> width fixes - #120
Merged
Merged
Conversation
Short summaries of every published release, and a detailed entry for the unreleased 0.12.0, including the wire-format fixes for exclusive byte ranges and wide unaligned fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every public item in packed_struct and packed_struct_codegen now has documentation, and both crates warn on missing docs. Existing docs that no longer matched the code are corrected: the LsbInteger example used a value that doesn't fit in 10 bits, sign extension was described as one's complement, the byte_types_* features only raise the Bits<N> limit since the const generic rewrite, and the attribute tables misdescribed size_bits, endian and the lsb0 requirements. The README gets the same fixes as the crate docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#[derive(PrimitiveEnum)] could pick a type too small for the discriminants. The i64 branch for negative values was unreachable, so -3000000000 became i32, and with mixed signs the signed type won regardless of the positive values, so -1 and 200 became i8. Both expanded into literals that don't fit and failed to compile. The type is now the smallest integer that holds both the smallest and the largest discriminant, and an enum that no type can hold is reported as a compile error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build script generated the bit widths with an exclusive range, so the widest type was one bit short: 255 bits by default, and 511 or 2047 bits with byte_types_64 or byte_types_256. A reserved field of exactly 32, 64 or 256 bytes, like ReservedZero<Bits<256>>, failed to compile. The range was inclusive until it lost its + 1 in 49809fd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lsb0 bit 0 is the least significant bit of the last byte, so the packed array reads as one big-endian number, and endian only orders the bytes inside each field. bit_numbering="lsb0" with endian="lsb" therefore does not describe a little-endian register, which is what #92 expected. The crate docs and the README now explain the numbering and show how to unpack a little-endian register. The issue 92 tests cover the register recipe and pin the layout of the struct from the report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
packed_structandpacked_struct_codegennow has docs, and both crates warn on missing docs. Docs that no longer matched the code are corrected, and the README gets the same fixes. The stale docs were:LsbIntegerexamplebyte_types_*features#[derive(PrimitiveEnum)]could pick a type too small for the discriminants. For example,-3000000000becamei32, and-1with200becamei8, so the derive failed to compile. It now picks the smallest integer that holds both the smallest and the largest discriminant. An enum that no integer type can hold is reported as a compile error.Bits<N>up to the full byte width. The build script used an exclusive range, so the widest type was one bit short. As a result,ReservedZero<Bits<256>>and the 64- and 256-byte equivalents failed to compile.lsb0bit numbering (Question on LSB0 endianness #92). Inlsb0, bit 0 is the least significant bit of the last byte, andendianonly orders the bytes inside each field. That meansbit_numbering="lsb0", endian="lsb"does not describe a little-endian register, which is what Question on LSB0 endianness #92 expected. This is a documentation gap, not a soundness bug. The docs now explain the numbering and include a runnable example for little-endian registers. New tests cover that example and pin the layout of the struct from the issue.Test plan
cargo test --workspace, including the new doctest andtests/issue_92.rs🤖 Generated with Claude Code