Closed
Description
It would be nice if _
were allowed instead of an expression for the length in array types and array expressions, in cases where the length can be inferred based on context:
fn main() {
let a: [u8; 4] = [0; _];
let b: [u8; _] = a;
}
rustc 1.17.0-nightly (b1e3176 2017-03-03)
error: expected expression, found `_`
--> a.rs:2:26
|
2 | let a: [u8; 4] = [0; _];
| ^
error: expected expression, found `_`
--> a.rs:3:17
|
3 | let b: [u8; _] = a;
| ^
error: aborting due to 2 previous error
In comparison, the item type in array expressions and array types can be inferred today:
fn main() {
let a: [u8; 4] = ["0".parse::<_>().unwrap(); 4];
let b: [_; 4] = a;
}