error: missing type for `const` item

error: missing type for `static` item

'_' を const または static のアイテムで使おうとした。

原因

'_' の未対応箇所』によると、'_' はconststatic のアイテムでは使えない。

サンプル


pub const VAL = 1_i32;

error: missing type for `const` item
 --> src\lib.rs:1:14
  |
1 | pub const VAL = 1_i32;
  |              ^ help: provide a type for the constant: `: i32`

解決策

以下のように型を明示するとよい。


pub const VAL: i32 = 1_i32;