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

leading_ones and trailing_ones missing for PrimInt #223

Closed
StephanvanSchaik opened this issue Oct 11, 2021 · 4 comments
Closed

leading_ones and trailing_ones missing for PrimInt #223

StephanvanSchaik opened this issue Oct 11, 2021 · 4 comments

Comments

@StephanvanSchaik
Copy link

It seems like the leading_ones() and trailing_ones() functions are missing for the PrimInt trait. However, I am not entirely sure why as the leading_zeros() and trailing_zeros() seem to be available.

While I could invert the bit representation and use the trailing_zeros() function for now, it would be convenient if I could just use the trailing_ones() function instead.

@cuviper cuviper transferred this issue from rust-num/num Oct 14, 2021
@cuviper
Copy link
Member

cuviper commented Oct 14, 2021

That's just history -- the _zeros functions have existed since Rust 1.0, but the _ones functions were only stabilized in 1.46.0. (I'm not sure when they were first added unstable.)

While I could invert the bit representation and use the trailing_zeros() function for now, it would be convenient if I could just use the trailing_ones() function instead.

That's exactly what the standard library functions do, literally (!self).trailing_zeros(), but we could also add those with the same default implementation in PrimInt.

@cuviper
Copy link
Member

cuviper commented Oct 14, 2021

Actually, #205 already added these -- I just haven't published a new version yet.

@StephanvanSchaik
Copy link
Author

Thanks for the clarification!

Is there any roadmap of when a new release of the num-traits crate will be published? I think that otherwise the issue is pretty much solved for me then.

@cuviper
Copy link
Member

cuviper commented May 4, 2022

I finally published that a couple days ago in 0.2.15.

@cuviper cuviper closed this as completed May 4, 2022
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

2 participants