utils icon indicating copy to clipboard operation
utils copied to clipboard

hex-literal: v1.0 tracker

Open newpavlov opened this issue 3 years ago • 2 comments

hex-literal is quite stable, with v0.3.0 being release over two years ago. So I think we can start to consider v1.0 release.

Potential changes:

  • [x] Bump MSRV to 1.56 and edition to 2021 (Done in v0.4)
  • [x] Decide whether we want to forbid comments inside literals or not, as described here (Done in v0.4)
  • [ ] Use https://github.com/rust-lang/cargo/issues/9930. It will allow us to bump hex-literal edition without breaking downstream builds and maybe incorporate new language features.
  • [ ] Use inline const {} expressions to force const evaluation (MSRV 1.79).
  • [ ] Wait for stabilization of generic_const_exprs and adt_const_params? It would allow us to write:
fn decode<const DATA: &'static [u8]>() -> [u8; decode_len(DATA)] { ... }

newpavlov avatar Oct 20 '22 22:10 newpavlov

It's possible to implement hex! macro with const evaluation. See const_str::hex!.

Nugine avatar Feb 21 '23 10:02 Nugine

Yeah, it works on Nightly and the code does not look too bad.

But this approach has the following disadvantages:

  1. hex::<"abcdef">() is... not great. Introducing a wrapper macro partially solves the issue, but ideally we would use const arguments. Unfortunately, it's highly unlikely that they will be added to the language. :(
  2. Error diagnostics are much worse. We can not even panic with message which includes encountered invalid character. With macros we potentially can point the exact place which triggers an error.

UPD: Migration to CTFE is done in #816.

newpavlov avatar Feb 21 '23 12:02 newpavlov

hex-literal v1.0.0 is released!

newpavlov avatar Feb 22 '25 15:02 newpavlov