-
Notifications
You must be signed in to change notification settings - Fork 543
all-your-base: Return domain-specific error #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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