What follows is just used as an example, and not valid Rust code.
struct Vec {
a: [T; Count]
}
Something like it
While waiting for Rust to gain first-class support for this, there are crates that provide certain levels of this functionality, such as:
This ability is not available yet. RFC 2000 — const generics will support it when it is implemented and progress is tracked in issue #44580.
In nightly Rust, your example would look like:
#![feature(const_generics)]
struct Vec<T: Sized, const COUNT: usize> {
a: [T; COUNT],
}
If you look at the design of Rust, you will notice that it started first by tackling the hardest problems (memory-safe, data-race free) but there are otherwise lots of areas where it is "incomplete" (compared to what could be achieved).
In particular, generic structures and functions are somewhat limited today:
For the moment, those are not implemented, not because they are not desired but simply because time was lacking. The idea of Rust 1.0 was not to release a final product that would not evolve, but a stable base from which to start; some or maybe all will come.