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

Consider a trait for NonZero* integers #215

Open
raphaelcohn opened this issue May 19, 2021 · 2 comments
Open

Consider a trait for NonZero* integers #215

raphaelcohn opened this issue May 19, 2021 · 2 comments

Comments

@raphaelcohn
Copy link

I wanted a trait to identify NonZero* integers (eg NonZeroU32) and my first thought was this crate. I didn't seem a trait for them.

In my very specific use case, I actually need a trait that relates the zero and non-zero unsigned integers. Of course, I can trivially create one, but this seems more useful in this pseudo-standard Rust crate.

For example:-

trait NonZeroInteger
{
}

impl NonZeroInteger for NonZeroU32
{
}

and possibly

trait Integer
{
    type NonZeroInteger: NonZeroInteger
}

I suppose there's a debate to be had as to whether NonNull would also implement such a trait. I'd argue not - rather there should be a super trait of NonZero and a sub trait of NonZeroInteger - but that's quite arguable either way.

@geeknoid
Copy link

geeknoid commented Aug 8, 2024

See #85

@tarcieri
Copy link
Contributor

tarcieri commented Aug 8, 2024

Also std::num::NonZero provides a generic solution

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

No branches or pull requests

3 participants