上級 › E0284: type annotations needed の原因と直し方 › パターン5
E0284: type annotations needed の原因と直し方
parse()のように戻り値の型がジェネリックで、文脈からも型を一意に決められない場合、E0284エラーになります。
1 fn main() { 2 let level_____ = "3".parse().unwrap(); ^ 3 println!("{}", level); 4 }
error[E0284]: type annotations needed
空欄を埋めて実行を通す
letに型注釈を付けるのが最もシンプルな解決方法で、他の型が欲しい場合はi32をf64などに変えるだけです。
次の問題