When to be explicit with type annotation?

I read Rust programming language , but I could not find a clear answer to what is best for type annotation, in particular with primitive types.

For example, letting the compiler determine the type:

let v = true;

Or using explicit type annotation:

let v: bool = true;

In general, I like to be explicit, but I'm not sure if this is against best practices or a preferred style. Will compilation time be improved due to the fact that the compiler does not have to deduce the type?

+6
source share
1 answer

against best practices or preferred style

Yes, I would say that the prevailing style is to allow the conclusion of the type as much as possible.

- , ?

, , , . , , , .

, , "" , .

,

, . , , , . , . , Rust ( " , ..." ).

, , ( , ) . , BTreeMap HashMap, -.

+4

All Articles