Skip to content

Commit 5c88fe4

Browse files
authored
hex-literal: add support for colon-delimited literals (#1244)
Colon-delimited literals are used by key hashes in Android signing key reports.
1 parent c210dd6 commit 5c88fe4

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hex-literal/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 1.1.0 (2025-10-29)
8+
### Added
9+
- Colon-delimited literals support ([#1244])
10+
11+
[#1244]: https://github.com/RustCrypto/utils/pull/1244
12+
713
## 1.0.0 (2025-02-22)
814
### Changed
915
- Edition changed to 2024 and MSRV bumped to 1.85 ([#1149])

hex-literal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hex-literal"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
authors = ["RustCrypto Developers"]
55
edition = "2024"
66
rust-version = "1.85"

hex-literal/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This crate provides the `hex!` macro for converting a sequence of hexadecimal st
1111
The macro accepts the following characters in input string literals:
1212

1313
- `'0'...'9'`, `'a'...'f'`, `'A'...'F'` — hex characters which will be used in construction of the output byte array
14-
- `' '`, `'\r'`, `'\n'`, `'\t'` — formatting characters which will be ignored
14+
- `' '`, `:`, `'\r'`, `'\n'`, `'\t'` — formatting characters which will be ignored
1515

1616
# Examples
1717
```rust
@@ -26,6 +26,9 @@ assert_eq!(hex!("a1 b2 c3 d4"), [0xA1, 0xB2, 0xC3, 0xD4]);
2626
assert_eq!(hex!("E5 E6 90 92"), [0xE5, 0xE6, 0x90, 0x92]);
2727
assert_eq!(hex!("0a0B 0C0d"), [10, 11, 12, 13]);
2828

29+
// Colon-delimited literals
30+
assert_eq!(hex!("0A:0B:0C:0D"), [10, 11, 12, 13]);
31+
2932
// Multi-line literals
3033
let bytes1 = hex!("
3134
00010203 04050607

hex-literal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fn next_hex_char(string: &[u8], mut pos: usize) -> Option<(u8, usize)> {
1313
b'0'..=b'9' => raw_val - 48,
1414
b'A'..=b'F' => raw_val - 55,
1515
b'a'..=b'f' => raw_val - 87,
16-
b' ' | b'\r' | b'\n' | b'\t' => continue,
16+
b' ' | b':' | b'\r' | b'\n' | b'\t' => continue,
1717
0..=127 => panic!("Encountered invalid ASCII character"),
1818
_ => panic!("Encountered non-ASCII character"),
1919
};

0 commit comments

Comments
 (0)