Drop decimal and octal support from bytes macros#44
Open
leighmcculloch wants to merge 4 commits intomainfrom
Open
Drop decimal and octal support from bytes macros#44leighmcculloch wants to merge 4 commits intomainfrom
leighmcculloch wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR narrows the bytes! and bytesmin! proc-macros to accept only hex (0x) and binary (0b) integer literals, removing support for decimal and octal forms and replacing prior behavior/tests with explicit compile errors.
Changes:
- Enforced hex/binary-only literal forms in
bytesandbytesminimplementations, emitting a targeted compile error for other bases. - Updated crate-level documentation examples to use
0x-prefixed literals and explicitly state decimal/octal are unsupported. - Replaced decimal/octal behavioral tests with tests asserting the new compile error output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib.rs | Updates macro documentation to reflect hex/binary-only support and adjusts examples accordingly. |
| src/bytes.rs | Rejects non-0x/0b literals and updates tests to assert the new compile error for decimal/octal inputs. |
| src/bytesmin.rs | Adds non-0x/0b rejection logic and updates tests to assert the compile error for decimal/octal inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What
Restrict
bytes!andbytesmin!to hex (0x) and binary (0b) integer literals only. Decimal and octal inputs now produce a compile error with a message directing users to hex or binary. Updates documentation and removes tests for the dropped forms, replacing them with tests that assert the compile error is emitted.Why
Decimal and octal are uncommon ways to express byte data and were never an intentional design goal. Supporting them adds maintenance burden for edge cases (e.g. leading zero handling #41) that don't serve the crate's core purpose of specifying binary data in hex or binary notation. Because removal produces a compile error rather than a silent behavior change, users who relied on these forms will see an immediate, actionable failure.
Close #41
Close #42
Downstream
The soroban-sdk will be updated to use the new version and its docs that it exposes about the macros will need updating as well.
Merging
Intending for merging tomainafter #43.