utils
utils copied to clipboard
hex-literal: v1.0 tracker
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-literaledition 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_exprsandadt_const_params? It would allow us to write:
fn decode<const DATA: &'static [u8]>() -> [u8; decode_len(DATA)] { ... }
It's possible to implement hex! macro with const evaluation. See const_str::hex!.
Yeah, it works on Nightly and the code does not look too bad.
But this approach has the following disadvantages:
-
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. :( - 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.
hex-literal v1.0.0 is released!