Another question shows two ways that you can force the return type of rand::random
inside another expression. These two ways are: using type ascription
println!("{}", rand::random(): f64);
or using the turbofish operator
println!("{}", rand::<f64>random() );
These are telling the compiler different things, which work out the same in this case, but not in general. The first is saying that the return type is f64
and letting the compiler deduce the type used for the type parameter from that, while the second is explicitly specifying the generic type parameter.
In this case, the difference is only minimal, but are there cases where
I) The compiler can not deduce the type without one of turbofish or type ascription, and
II) The type ascription form is considerably more concise than the turbofish form?