Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions exercises/05_vecs/vecs1.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
fn array_and_vec() -> ([i32; 4], Vec<i32>) {
let a = [10, 20, 30, 40]; // Array
// You can define an array with the intitial values 10, 20, 30 and 40 like
// this:
let a = [10, 20, 30, 40]; // Array. Do not change!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original example already shows it’s just array initialization, so it works well. Still, it might be good to see the maintainer’s opinion.


// TODO: Create a vector called `v` which contains the exact same elements as in the array `a`.
// Use the vector macro.
// let v = ???;
// There is a similar way you can define a vector with initial values:
// let v = vec![10, 20, ???]; // Vector. Needs to be fixed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both to_vec() and Vec::from compile, but the author just wanted vec![10, 20, 30, 40]. So I think the original is fine — let’s see the maintainer’s opinion.


// TODO: Adjust the vector definition above so that `a` and `v` have the
// same contents.

(a, v)
}
Expand Down