Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercises/05_vecs/vecs1.rs: TODO clarification #2194

Open
hikojlu opened this issue Jan 7, 2025 · 4 comments
Open

exercises/05_vecs/vecs1.rs: TODO clarification #2194

hikojlu opened this issue Jan 7, 2025 · 4 comments

Comments

@hikojlu
Copy link

hikojlu commented Jan 7, 2025

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)

@frroossst
Copy link
Contributor

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

@jyap808
Copy link

jyap808 commented Feb 14, 2025

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]];

@temanmd
Copy link

temanmd commented Feb 19, 2025

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

@mo8it
Copy link
Contributor

mo8it commented Feb 19, 2025

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

Yes, but many people get confused by this exercise, so I will do something to make the intention clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants