Closed
Description
If I declare a const
array, I need to give it a specific size, in this case 2.
const NUMBERS: [u8; 2] = [
10,
20
];
When I add or remove a number from the initialiser, the compiler will complain that the listed array length is now wrong. It would be convenient to have a quick fix, which amends the explicit size to match the true number of items in the array.
Here's an example of the fix that I would like applied, changing the array type from [u8; 2]
to [u8; 3]
.
const NUMBERS: [u8; 2] = [
10,
20,
30
]; // mismatched types, expected array `[u8; 2]`, found array `[u8; 3]`
->
const NUMBERS: [u8; 3] = [
10,
20,
30
];