-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Tracking Issue for isolate_most_least_significant_one
#136909
Labels
C-tracking-issue
Category: An issue tracking the progress of sth. like the implementation of an RFC
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Comments
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this issue
Feb 22, 2025
Implement feature `isolate_most_least_significant_one` for integer types Accepted ACP - rust-lang/libs-team#467 Tracking issue - rust-lang#136909 Implement ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and `NonZero` integers. Add function `isolate_most_significant_one` Add function `isolate_least_significant_one` --- This PR adds the following impls ```rust impl {u8, u16, u32, u64, u128, usize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl {i8, i16, i32, i64, i128, isize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl NonZeroT { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } ``` Example behavior ```rust assert_eq!(u8::isolate_most_significant_one(0b01100100), 0b01000000); assert_eq!(u8::isolate_least_significant_one(0b01100100), 0b00000100); ```
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Feb 22, 2025
Implement feature `isolate_most_least_significant_one` for integer types Accepted ACP - rust-lang/libs-team#467 Tracking issue - rust-lang#136909 Implement ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and `NonZero` integers. Add function `isolate_most_significant_one` Add function `isolate_least_significant_one` --- This PR adds the following impls ```rust impl {u8, u16, u32, u64, u128, usize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl {i8, i16, i32, i64, i128, isize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl NonZeroT { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } ``` Example behavior ```rust assert_eq!(u8::isolate_most_significant_one(0b01100100), 0b01000000); assert_eq!(u8::isolate_least_significant_one(0b01100100), 0b00000100); ```
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Feb 22, 2025
Rollup merge of rust-lang#136910 - okaneco:sig_ones, r=thomcc Implement feature `isolate_most_least_significant_one` for integer types Accepted ACP - rust-lang/libs-team#467 Tracking issue - rust-lang#136909 Implement ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and `NonZero` integers. Add function `isolate_most_significant_one` Add function `isolate_least_significant_one` --- This PR adds the following impls ```rust impl {u8, u16, u32, u64, u128, usize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl {i8, i16, i32, i64, i128, isize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl NonZeroT { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } ``` Example behavior ```rust assert_eq!(u8::isolate_most_significant_one(0b01100100), 0b01000000); assert_eq!(u8::isolate_least_significant_one(0b01100100), 0b00000100); ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-tracking-issue
Category: An issue tracking the progress of sth. like the implementation of an RFC
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Feature gate:
#![feature(isolate_most_least_significant_one)]
This is a tracking issue for functions that return an integer with only the most significant set bit or only the least significant set bit masked from the input integer.
The functions are implemented for unsigned, signed, and
NonZeroT
integer types.Public API
Steps / History
least_significant_one
andmost_significant_one
to integer types andNonZero
types libs-team#467isolate_most_least_significant_one
for integer types #136910Unresolved Questions
Function name length
The initial function names are taken from the libs-api suggestions in the ACP, but they are quite verbose.
The names need to indicate that the integer being returned is the input with only the most/least significant set bit and not whether the most/least significant bit is 0 or 1. Hence,
isolate
is suggested as a prefix to disambiguate the meaning.Possible names (non-exhaustive):
isolate_least_significant_one
/isolate_most_significant_one
least_sig_one
/most_sig_one
lowest_one
/highest_one
lowest_bit_set
/highest_bit_set
isolate_lowest_one
/isolate_highest_one
trailing_one
/leading_one
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: