Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upimplement .trailing_ones(), .leading_ones() #55715
Conversation
rust-highfive
assigned
KodrAus
Nov 6, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @KodrAus (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
rust-highfive
added
the
S-waiting-on-review
label
Nov 6, 2018
killercup
reviewed
Nov 6, 2018
src/libcore/num/mod.rs Outdated
| assert_eq!(n.leading_ones(), 0);", | ||
| $EndFeature, " | ||
| ```"), | ||
| #[unstable(feature = "leading_ones_trailing_ones", issue = "0")] |
This comment has been minimized.
This comment has been minimized.
killercup
Nov 6, 2018
Member
Not on the libs team but it might be a good idea to open an issue so you have a non-zero number you can refer to here :)
yoshuawuyts
force-pushed the
yoshuawuyts:trailing_ones_trailing_zeros
branch
2 times, most recently
from
88eec03
to
7fb7422
Nov 6, 2018
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
scottmcm
reviewed
Nov 6, 2018
| ``` | ||
| ", $Feature, "let n = 0b10110011", stringify!($SelfT), "; | ||
| assert_eq!(n.leading_ones(), 1);", |
This comment has been minimized.
This comment has been minimized.
scottmcm
Nov 6, 2018
Member
I don't think this will pass -- this will have no leading ones for any type size but u8.
scottmcm
reviewed
Nov 6, 2018
| Basic usage: | ||
| ``` | ||
| ", $Feature, "let n = 0b10110011", stringify!($SelfT), "; |
This comment has been minimized.
This comment has been minimized.
scottmcm
Nov 6, 2018
Member
Tidy is saying that you need #![feature(leading_ones_trailing_ones)] in the doctests.
kennytm
added
the
T-libs
label
Nov 14, 2018
XAMPPRocky
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Nov 25, 2018
This comment has been minimized.
This comment has been minimized.
|
Triage; @yoshuawuyts Hello, have you been able to get back this PR? |
This comment has been minimized.
This comment has been minimized.
|
@Aaronepower Thanks for reaching out! Ooph, no -- I've been super busy, and about to go on holiday. If it's not too much trouble, I'd love to keep this open for a few more weeks so I can hack on it once I'm back. |
TimNN
added
A-allocators
and removed
A-allocators
labels
Dec 4, 2018
This comment has been minimized.
This comment has been minimized.
|
ping from triage @yoshuawuyts any updates on this? |
This comment has been minimized.
This comment has been minimized.
|
@Dylan-DPC not yet; haven't forgotten about it! -- I'm planning to tackle this next week! |
This comment has been minimized.
This comment has been minimized.
|
Ping from triage @yoshuawuyts: What is the status of this PR? |
Centril
reviewed
Jan 27, 2019
| $EndFeature, " | ||
| ```"), | ||
| #[unstable(feature = "leading_ones_trailing_ones", issue = "0")] | ||
| #[rustc_const_unstable(feature = "const_int_ops")] |
This comment has been minimized.
This comment has been minimized.
Centril
Jan 27, 2019
Contributor
I'd just remove this; I think it's fairly certain that we'll want it to be const fn when stabilizing.
| $EndFeature, " | ||
| ```"), | ||
| #[unstable(feature = "leading_ones_trailing_ones", issue = "0")] | ||
| #[rustc_const_unstable(feature = "const_int_ops")] |
This comment has been minimized.
This comment has been minimized.
| assert_eq!(n.leading_ones(), 2);", $EndFeature, " | ||
| ```"), | ||
| #[unstable(feature = "leading_ones_trailing_ones", issue = "0")] | ||
| #[rustc_const_unstable(feature = "const_int_ops")] |
This comment has been minimized.
This comment has been minimized.
| assert_eq!(n.trailing_ones(), 2);", $EndFeature, " | ||
| ```"), | ||
| #[unstable(feature = "leading_ones_trailing_ones", issue = "0")] | ||
| #[rustc_const_unstable(feature = "const_int_ops")] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Update: I've spent some time building this out again yesterday, but ran into build problems with Rust itself. Sorry this is taking a while! |
yoshuawuyts
referenced this pull request
Jan 29, 2019
Open
Tracking issue for `.trailing_ones()` + `leading_ones()` #57969
This comment has been minimized.
This comment has been minimized.
|
Created an issue for this PR in #57969. If someone else would like to carry this PR over the finish line that'd be grand! -- I feel we're really close; it just requires passing lints + feature labels. |
This comment has been minimized.
This comment has been minimized.
|
ping from triage @yoshuawuyts closing this due to inactivity and since you are not planning of taking this forward. Thanks! |
yoshuawuyts commentedNov 6, 2018
Hi!
This patch implements
.trailing_ones()and.leading_ones()to all number types as counterparts to the.leading_zeros(), and.trailing_zeros()methods.I posted a pre-RFC for these changes on internals, but the consensus seemed to be these changes would be small enough that no RFC was needed. So hence this patch!
I've never written a PR for Rustc before, so I hope I'm doing everything right. I realize this patch is probably not good enough to land as-is, so I had a few questions:
tidychecks are pointing out it's malformed, but I'm not sure what the correct form would be.Thanks heaps!