Though type inference is great in Rust, sometimes we still need explicit type annotation.
// Ideal, but doesn't work due to lack of collection type information. let a = [1,2,3].iter().collect(); // Works, but suboptimal as we need to put type annotation. let b: Vec<&i32> = [1,2,3].iter().collect();
If we cannot eliminate the type annotation,
how do you think about moving type annotation to the end with
// Optimal IMO. // Provide collection type information with `as` keyword. let c = [1,2,3].iter().collect() as Vec<&i32>;
Swift supports this kind of inference in limited context and this makes code more readable IMO.