Closed
Description
The idiomatic solution for generics1
is to simply remove the explicit type from the variable binding since it can be inferred:
fn main() {
let mut shopping_list = Vec::new();
shopping_list.push("milk");
}
The hint says:
Vectors in Rust make use of generics to create dynamically sized arrays of any type.
You need to tell the compiler what type we are pushing onto this vector.
Two problems with this:
- The solution is better without specifying a type and thus is not teaching/requiring the explicit use of generics
- The hint is wrong, because there is not need to tell the compiler the type
Metadata
Metadata
Assignees
Labels
No labels