Skip to content

Comments

Drop decimal and octal support from bytes macros#44

Open
leighmcculloch wants to merge 4 commits intomainfrom
remove-dec-oct
Open

Drop decimal and octal support from bytes macros#44
leighmcculloch wants to merge 4 commits intomainfrom
remove-dec-oct

Conversation

@leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Feb 24, 2026

What

Restrict bytes! and bytesmin! 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 to main after #43.

@leighmcculloch leighmcculloch requested review from a team and Copilot February 24, 2026 07:17
@leighmcculloch leighmcculloch marked this pull request as ready for review February 24, 2026 07:17
@leighmcculloch leighmcculloch changed the base branch from zero to main February 24, 2026 07:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 bytes and bytesmin implementations, 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.

@leighmcculloch leighmcculloch enabled auto-merge (squash) February 24, 2026 10:37
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.

Remove support for decimal and octal literal forms bytes! macro rejects zero literal in decimal and octal forms

1 participant