Yes, const
can be used on a variable (to indicate that the variable’s value can’t change) or as a pointer qualifier (to indicate that you can’t change the value pointed to through that pointer).
The key distinction here is that arrays, such as [2]i32
, are values rather than pointers, just like other familiar value types such as i64
. So just as it wouldn’t make sense to have const i64
as a separate type from i64
, it also wouldn’t make sense to have a type [2]const i32
. For more information on what it means to apply const
to a variable vs as a pointer qualifier, see Converting an "array of slices" to a "slice of slices" - #5 by ianprime0509