Skip to content

Commit

Permalink
A clearer description of the original problem
Browse files Browse the repository at this point in the history
The original excercise instructs the learner to use the vector macro.
It is easy to assume that the code needs to read from `a` which is not
what is intended.

The updated excercise introduces the syntax for initial array and vector
contents and lets the learner figure out how to tweak initial values of
a vector. This learning seems to be the original intent of the
excercise.
  • Loading branch information
Jörn Bethune committed Jan 1, 2025
1 parent bde6f74 commit a351636
Showing 1 changed file with 8 additions and 4 deletions.
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!

// 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![20, 30, 40]; // Vector. Needs to be fixed

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

(a, v)
}
Expand Down

0 comments on commit a351636

Please sign in to comment.