Accumulate start

Exercise starts as

/// What should the type of _function be?
pub fn map(input: Vec<i32>, _function: ???) -> Vec<i32> {
    todo!("Transform input vector {input:?} using passed function");
}

but the tests clearly contain inputs and outputs that are different from Vec<i32>. Should the starting state of exercise be something like the following code?

/// What should the type of _function be?
pub fn map<T, U>(input: Vec<T>, _function: ???) -> Vec<U> {
    todo!("Transform input vector {input:?} using passed function");
}

No, this is intentional. The hints state:

The tests for this exercise will cause compile time errors, if your function signature does not fit them, even when theyā€™re not run. You may want to comment some tests out and generalize your solution piece by piece.

Adding generics to the stub would take something away that students are supposed to figure out on their own. The type signature is the difficult part here, not the implementation.

Agreed, though I didnā€™t see the hint. When does it get displayed? When a submission fails?

Hm. With the CLI-based workflow, itā€™s appended to the instructions. But I was having trouble finding it on the website myself. Found it in the endā€¦ the right sidebar has a bunch of tabs (instructions, tests, resultsā€¦) the very last one is ā€œget helpā€

Iā€™ll see if I can move this part to a more discoverable spot.

Perhaps moving it to the exercise instructions might be a better idea? I guess the tests are supposed to fail for most of the people trying to solve the exercise.

Iā€™ll leave it to you. Either way, thanks for having a look.

Yes, Iā€™m moving it to the instructions:

2 Likes