How far away are we from getting rid of typenums and generic arrays?

I've always thought that typenums and generic arrays are a compromise product of underdeveloped language features such as const generics, and should be swept into the dustbin of history once the language features are well developed (at least in cases where there is no MSRV requirement).
I have a taste of rewriting Rust Crypto traits with const generics and found that even with the nightly compiler and generic_const_exprs turned on, there were still obstacles such as associated const numbers in traits cannot being limited in a certain interval, and while expressing semantics like Key<Self> there seems to be some strange difficulties, and the compiler output is unintelligible (there seems to be a post here with a similar situation).
Preparing to post, I discovered that Rust Crypto had made some incremental progress a year ago. Not sure how it's evolving now.


I think they mean not "will something be phased out from the language?", but "will the crates like Typenum — Rust library // and generic-array — data structures in Rust // be ever deprecated in favor of const generics?"


@stackinspector the latest prereleases of hybrid-array make use of GATs and are what we'll be using to try to upgrade the RustCrypto crates.

That said there haven't been major new stabilizations of const generic features in the time since the initial release. The big one for hybrid-array would be generic_const_exprs, although when that's sufficiently powerful hopefully we can use it to replace typenum bounds with proper const generics.


How to impl things like crypto_common::BlockSizes with const generics?
About min-max limiting on const generic number values made me think of this.

For now, hybrid-array still uses typenum for expressing those same constraints, lacking the expressiveness we need from const generics.

In the future, generic_const_exprs should make it possible to express these bounds as an expression, e.g. BLOCK_SIZE > 0 && BLOCK_SIZE < 256.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.