nth-prime tests use the wrong indexes
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.nth
"Like most indexing operations, the count starts from zero, so nth(0) returns the first value, nth(1) the second, and so on."
However, the tests for nth-prime expect to find the first prime after calling nth(1), the second at nth(2) etc. For example:
#[test]
fn test_first_prime() {
assert_eq!(np::nth(1), Some(2));
}
I could hack my solution to conform to this expectation, but that would involve putting a fudge in my Iterator implementation which I shouldn't have to do.
Changing this would break every solution currently submitted though...
While this exercise is not obligated to adhere to the same interface semantics as Iterator, because of the similarity in signature, it would be surprising if it did not, and we'd like to promote good habits and lessen surprise. So it could make sense to 0-index here. A clarifying comment in either the tests or README could help.
I wonder if https://github.com/exercism/problem-specifications/blob/master/exercises/nth-prime/canonical-data.json should change. But since some languages may 1-index and others 0-index, I think either way some languages will have to make a decision on what to do.
Changing this would break every solution currently submitted though...
True, but if everyone agrees the current tests are broken, then not changing this would break all future solutions, so the change has to be made.
Now, the website claims to handle test suite changes well, by remembering which test suite each individual student downloaded (I acquired this information from https://github.com/exercism/exercism/issues/4266). I can't speak to how clearly it shows the differing versions when viewing others' solutions as either a student or a mentor, since I have not attempted to do either of these things, but it looks like there is discussion to make that right.