-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(int_lowest_highest_one)]
This is a tracking issue for the lowest_one
and highest_one
methods on primitive integer types and their NonZero
counterparts.
These methods provide an efficient way to find the index of the least significant (lowest
) and most significant (highest
) set bit in an integer. They are common, low-level operations often supported directly by hardware (e.g. BSF
/BSR
on x86) and frequently used in systems programming, such as in OS kernels for managing bitmasks.
Public API
impl {u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize} {
const fn lowest_one(self) -> Option<u32>;
const fn highest_one(self) -> Option<u32>;
}
// For all `T` in the impl block above.
impl NonZero<T> {
const fn lowest_one(self) -> u32;
const fn highest_one(self) -> u32;
}
Steps / History
- Implementation:
- ACP Accepted with amendments:
first_set_bit
andlast_set_bit
for integer types libs-team#631 - Implementation PR: Implement feature
int_lowest_highest_one
for integer and NonZero types #145381
- ACP Accepted with amendments:
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
None.
Resolved Questions
- Methods name
- Although the general agreement is to use
lowest_one
andhighest_one
, we want to maintain consistency with ACP: addleast_significant_one
andmost_significant_one
to integer types andNonZero
types libs-team#467 (Tracking Issue forisolate_most_least_significant_one
#136909). - Renaming done by PR num: Rename
isolate_most_least_significant_one
functions #144971, which seems to confirmlowest_one
andhighest_one
for this feature.
- Although the general agreement is to use
Footnotes
wmstack
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.