上級 › E0284: type annotations needed の原因と直し方 › パターン1
E0284: type annotations needed の原因と直し方
parse()のように戻り値の型がジェネリックで、文脈からも型を一意に決められない場合、E0284エラーになります。
1 fn main() { 2 let n_____ = "42".parse().unwrap(); ^ 3 println!("{}", n); 4 }
error[E0284]: type annotations needed
空欄を埋めて実行を通す
parseはジェネリックな戻り値を持ち、以降の使い方からも型が決まらない場合、型注釈が必要になります。
次の問題