Skip to content
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

Luhn From #19

Merged
merged 2 commits into from
Nov 3, 2024
Merged

Luhn From #19

merged 2 commits into from
Nov 3, 2024

Conversation

adnilsson
Copy link
Owner

Description

Solution to the Luhn From exercise.

Mentoring

No mentoring was requested since the solution is straightforward.

Other

I had planned to also inlcude a TryFrom implementation since that is essentially what Luhn::from().is_valid() does. However, I encountered this error. As it turns out, you can't implement both From and TryFrom:

If you implement From<T> for U it auto implements Into<U> for T and therefore it auto implements TryFrom<T> for U.

Any type that can be made into a string can be put into the Luhn type.
@adnilsson adnilsson merged commit a737bf7 into main Nov 3, 2024
@adnilsson adnilsson deleted the luhn-from branch November 3, 2024 20:55
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.

1 participant