Should i let rust do type inference or be explicit

61 points Character_Glass_7568 54 comments

Hi just a beginner. ive been learning rust for the past few days and one thing that kinda bugs me is that i always explictly state the type of the var but most of the examples in the rust book does implict type annotation.For instance ,

the book does
let x = 5;

while i usually do

let x: i32 = 5;

ik rust has strong type inference and is mostly accurate (vscode using rust-analyser). I heard that one of rust strong features is its strong type inference. I get that but wouldnt it be slighlty faster if we tell the compiler ahead of time wht the variable type is gonna be?