Skip to content

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

Merged
merged 2 commits into from
Apr 4, 2018
Merged

all-your-base: Return domain-specific error #469

merged 2 commits into from
Apr 4, 2018

Conversation

petertseng
Copy link
Member

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

}

// 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) {
Copy link
Member Author

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.

Copy link
Member

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 *.

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
@petertseng
Copy link
Member Author

petertseng commented Apr 4, 2018

last reviewed: e62e97e

regular diff: git diff e62e97ee3371fa8dd8fd32b6677756240b4e0ecf 99e951d exercises/all-your-base : README regeneration only.

diff-of-diff: diff -u <(git diff e62e97ee3371fa8dd8fd32b6677756240b4e0ecf~ e62e97ee3371fa8dd8fd32b6677756240b4e0ecf) <(git diff 99e951d~ 99e951d) - no change

thus, I'm taking the most recent approval as authoritative

@petertseng
Copy link
Member Author

I see that the stub compilation check has made itself useful already.

@petertseng petertseng merged commit ccc6f0f into exercism:master Apr 4, 2018
@petertseng petertseng deleted the ayb branch April 4, 2018 18:19
UnlimitedHummus added a commit to UnlimitedHummus/exercism-rust that referenced this pull request Sep 12, 2023
Update instructional comment to match changes from exercism#469
UnlimitedHummus added a commit to UnlimitedHummus/exercism-rust that referenced this pull request Sep 12, 2023
Update instructional comment to match changes from exercism#469.
senekor pushed a commit that referenced this pull request Sep 12, 2023
Update instructional comment to match changes from #469.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants