是否可以在不重复长度的情况下声明指定类型的静态数组?

Is it possible to declare a static array of specified type without repeating the length?

我的理解是

let x: [i16; 256] = [0; 256];

是声明 i16 静态数组并用零初始化它的惯用方法。有什么办法可以重复长度吗?例如,为什么不编译:

let x: [i16; 256] = [0; _];

Rust 执行类型推断,因此您通常可以省略变量的类型。

fn main() {
    let x = [0i16; 256];
}

playground