Skip to content

Commit d9965cc

Browse files
committed
hex-literal: enforce const evaluation
1 parent 13385f6 commit d9965cc

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

Cargo.lock

Lines changed: 5 additions & 5 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+
## 0.4.1 (2023-04-05)
8+
### Changed
9+
- Enforce const evaluation ([#886])
10+
11+
[#886]: https://github.com/RustCrypto/utils/pull/886
12+
713
## 0.4.0 (2023-04-02)
814
### Changed
915
- Disallow comments inside hex strings ([#816])

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 = "0.4.0"
3+
version = "0.4.1"
44
authors = ["RustCrypto Developers"]
55
license = "MIT OR Apache-2.0"
66
description = "Macro for converting hexadecimal string to a byte array at compile time"

hex-literal/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ pub const fn decode<const LEN: usize>(strings: &[&[u8]]) -> [u8; LEN] {
8181
macro_rules! hex {
8282
($($s:literal)*) => {{
8383
const STRINGS: &[&'static [u8]] = &[$($s.as_bytes(),)*];
84-
$crate::decode::<{ $crate::len(STRINGS) }>(STRINGS)
84+
const LEN: usize = $crate::len(STRINGS);
85+
const RES: [u8; LEN] = $crate::decode(STRINGS);
86+
RES
8587
}};
8688
}

0 commit comments

Comments
 (0)