Add fmt_hex_exact_lower and fmt_hex_exact_upper macros#247
Open
alexgrad42 wants to merge 1 commit into
Open
Conversation
a32d557 to
a1c5829
Compare
Member
|
concept ACK. can you undraft? |
a1c5829 to
be4b0ed
Compare
Member
|
New discussion on the issue needs addressing please mate. Thanks for the prompt contribution also! |
e4f09d5 to
d0726a9
Compare
Kixunil
requested changes
May 12, 2026
| /// ## Panics | ||
| /// | ||
| /// This macro panics if `$len` is not equal to `$bytes.len()` | ||
| /// |
Collaborator
There was a problem hiding this comment.
This shouldn't be removed, rather it should be updated to say that it will panic if the length of the encoded item is larger than $len.
Contributor
Author
There was a problem hiding this comment.
Done, please check
| // statically check $len | ||
| #[allow(deprecated)] | ||
| const _: () = [()][($len > usize::MAX / 2) as usize]; | ||
| $crate::display::fmt_hex_max_fn::<_, { $len * 2 }>($formatter, $bytes, $case) |
Collaborator
There was a problem hiding this comment.
Length check is missing here.
Contributor
Author
There was a problem hiding this comment.
Done, please check
d0726a9 to
1e29af7
Compare
- Added fmt_hex_max! macro which provides compile-time verification of the length. - Added fmt_hex_lower! and fmt_hex_upper! macros for convenient hex formatting. Fixes: rust-bitcoin#246
1e29af7 to
a9d2032
Compare
Kixunil
approved these changes
May 15, 2026
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.
The implementation wraps the existing
fmt_hex_exact!macro to minimize code duplication and keep it clean.Fixes: #246