Skip to content

Tracking Issue for int_lowest_highest_one #145203

Description

@Gnurou

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

Unresolved Questions

None.

Resolved Questions

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions