When do you need to use type annotations?
问题 While reading Data Types from the Rust Book I noticed that sometimes a variable is defined with a type annotation and sometimes not. When should I use type annotations? let tup: (i32, f64, u8) = (500, 6.4, 1); let tup = (500, 6.4, 1); let months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; let a: [i32; 5] = [1, 2, 3, 4, 5]; 回答1: When types have to be specified If the compiler cannot infer the type by itself, it