exercises/05_vecs/vecs1.rs: TODO clarification
exercises/05_vecs/vecs1.rs:
let a = [10, 20, 30, 40];
// TODO: Create a vector called `v` which contains the exact same elements as in the array `a`
// Use the vector macro
vec! macro can only be used like this: vec![10, 20, 30, 40].
Is it intended to be like this? I guess, it would make more sense to use Vec::from(a)
I think what the exercise intended was vec![10, 20, 30, 40]
Although it wouldn't make much of a difference if you use Vec::from or the vec! macro
The alternative which references the a array and per the instructions uses the vec! macro:
let v = vec![a[0], a[1], a[2], a[3]];
I think you try to overengineering this :)
The exercise is not about reusing memory or about references, its just about using vec! macro, just it
So to use vec![10, 20, 30, 40] is absolutely normal solution
I think you try to overengineering this :) The exercise is not about reusing memory or about references, its just about using
vec!macro, just it So to usevec![10, 20, 30, 40]is absolutely normal solution
Yes, but many people get confused by this exercise, so I will do something to make the intention clear.
I think the wording "which contains the exact same elements as" heavily suggests that you're supposed to somehow tell Rust to reuse the existing array elements, which is what tripped me up since it felt like a sudden escalation of difficulty compared to the exercises before