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

Add TryConvert for NonZero types #120

Merged
merged 1 commit into from
Oct 6, 2024
Merged

Conversation

ankane
Copy link
Contributor

@ankane ankane commented Oct 4, 2024

This PR adds support for NonZero types, which is part of std::num.

I tried using NonZero<T>, but ZeroablePrimitive is a nightly trait, so used a macro instead. It raises an ArgumentError if the value is zero, but I think a TypeError would work as well.

Edit: Switched to NonZeroI8, NonZeroI16, etc. since NonZero<T> is not available in 1.61.

@matsadler
Copy link
Owner

Thank you! This looks good. Could you rebase on main, that should fix the failing tests, and then I'll merge this.

@matsadler matsadler merged commit faad142 into matsadler:main Oct 6, 2024
43 checks passed
@ankane
Copy link
Contributor Author

ankane commented Oct 6, 2024

Thanks @matsadler!

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