<ao> | Adetunji's Blog

Rust compiler is smart enough to infer types

I can do fine with just declaring my variables without explicitly typing them as the compiler is smart enough to infer them correctly but I might want to do something complex that the compiler might be in error of inferring wrong types then I can type out what type I want for my variables

let my_number: u8 = 230
OR
let my_number = 230_u8

Rust chooses i32 by default for integer types while it chooses f64 for float types f32 - 4 bytes f64 - 8 bytes

Rust also won't add floats of different types together, it will spill out error but rust is also smart enough to infer the correct types if no type is provided

#note #rust