all-your-base: Return domain-specific error#469
all-your-base: Return domain-specific error#469petertseng merged 2 commits intoexercism:masterfrom petertseng:ayb
Conversation
| // check that all digits are in the correct range specified by the base | ||
| if digits.as_ref().iter().any(|&num| num >= from_base) { | ||
| return Err("Digits invalid for input base"); | ||
| if let Some(&invalid) = digits.as_ref().iter().find(|&num| *num >= from_base) { |
There was a problem hiding this comment.
There is in fact not a specific reason I wrote find(|&num| *num >= from_base) as opposed to one of these two alternatives:
find(|&&num| num >= from_base)
find(|num| **num >= from_base)
I really don't know what I'm doing and which is better, so I need help on that.
There was a problem hiding this comment.
I am also unaware of any particular style guide suggestion as to which of those alternatives is ideal, but I like the symmetry of having equal numbers of & and *.
|
last reviewed: e62e97e regular diff: diff-of-diff: thus, I'm taking the most recent approval as authoritative |
|
I see that the stub compilation check has made itself useful already. |
Update instructional comment to match changes from exercism#469
Update instructional comment to match changes from exercism#469.
Update instructional comment to match changes from #469.
We prefer domain-specific errors to empty tuple because the former are
programmatically inspectable. We would prefer to encourage students to
use domain-specific errors rather than empty tuple.
As discussed in #444:
#444