|
|
|
|
|
by duped
198 days ago
|
|
> let v = Vec::new(); // Crap, I want to specify the type of Vec This kinda implies you've gone wrong somewhere. That doesn't mean there aren't cases where you need type annotations (they certainly exist!) but that if `Vec::new()` doesn't compile because the compiler couldn't deduce the type, it implies something is off with your code. It's impossible to tell you exactly what the problem was, just that `<Vec<T>>::new()` is not code that you would ever see in a Rust codebase. |
|
1. You don't want the default `i32` integer type and this is just a temporary vector of integers.
2. Rust's type inference is not perfect and sometimes the compiler will object even though there's only one type that could possibly work.
Edit: The <Vec<T>>::new() syntax is definitely never used though.