lifetimekata icon indicating copy to clipboard operation
lifetimekata copied to clipboard

Misleading hint in `ex04`

Open git-staus opened this issue 6 months ago • 1 comments

In this exercise the reader is supposed to write the function body and is assured like this: https://github.com/tfpk/lifetimekata/blob/1ad5235dd44ad235f762645d006aaf8f906f5f1c/exercises/04_mutable_references_and_containers/exercise/src/lib.rs#L36 so I wrote

vector[loc] = new

which is wrong of course (and caught by a test) because I forgot the requirement

Don't do anything if "loc" is beyond the end of "vector".

mentioned at the top of the file. So trying to follow the hint I wrote:

if loc < vector.len() { vector[loc] = new; }

However, the solution given is the following (multiline but more idiomatic) code: https://github.com/tfpk/lifetimekata/blob/1ad5235dd44ad235f762645d006aaf8f906f5f1c/exercises/04_mutable_references_and_containers/solutions/src/lib.rs#L39-L41

I guess the hint should simply be removed?

git-staus avatar Jun 13 '25 19:06 git-staus

The hint became outdated when #8 was merged.

In that PR, the requirement to not panic was added, see the changes for the solution file.

mjpieters avatar Aug 06 '25 16:08 mjpieters