Rust made good progress in 2018:
const fnin particular was a welcome and sorely needed feature.
#[panic_handler]now stable, we can finally write
no_stdbinary crates on stable and not worry the next release will break it.
- We got some other useful features, including the following:
NonNull, fixed-length slice patterns, LTO,
In 2019, i have one major wish for Rust:
The worst pain point for me, by far, is the inability to quantify over numbers. Notions as basic as an array of a
Eq type being
Eq are inexpressible in Rust now; see the ridiculous (and necessarily incomplete) list of impls for
[_; _]. (Edit(2018-12-23): I see
Clone is now magical. The infelicity remains for other traits such as
Ord.) We have kludges like “typenum” and “generic-array“, but consider the impl header for matrix multiplication in my matrix library:
impl<B: Copy, A: Copy + Mul<B>,
K: ArrayLength<B> + ArrayLength<GenericArray<A, M>>,
M: ArrayLength<A> + ArrayLength<A::Output>,
N: ArrayLength<GenericArray<A::Output, M>> + ArrayLength<GenericArray<B, K>>> Mul<Matrix<B, K, N>> for Matrix<A, M, K>
where A::Output: Zero + AddAssign
Writing all the
ArrayLength constraints is very tedious, and they are mere noise to a reader.
But the pain is deeper yet: these types are often part of the API, which makes me hesitate to stabilize such an API before we have const generics. (It also affects APIs which want to accept buffer sizes, for example.)
I hope at some point Rust will have a much richer kind system, letting users quantify over type constructors, arrays of types, and traits, at least. (See, for example, the broad utility of
Monad :: (Type → Type) → Constraint in Haskell.) But the most urgently needed is natural numbers.
Note(2018-12-27): I posted a follow-up.