about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/builtin.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-22 11:36:42 +0100
committerGitHub <noreply@github.com>2025-02-22 11:36:42 +0100
commit1df3a35bca9ff2c23073fabc2d7e6e336d7790f6 (patch)
tree4f7afff7051cbc35afd3087b8b53bd19f276fc53 /compiler/rustc_lint/src/builtin.rs
parentb6d3be4948e92fce0236cbbe22b55c55f6950269 (diff)
parent97bc99a18f8175bf251a902fe5956e4d42fecebb (diff)
downloadrust-1df3a35bca9ff2c23073fabc2d7e6e336d7790f6.tar.gz
rust-1df3a35bca9ff2c23073fabc2d7e6e336d7790f6.zip
Rollup merge of #136910 - okaneco:sig_ones, r=thomcc
Implement feature `isolate_most_least_significant_one` for integer types

Accepted ACP - https://github.com/rust-lang/libs-team/issues/467
Tracking issue - #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);
```
Diffstat (limited to 'compiler/rustc_lint/src/builtin.rs')
0 files changed, 0 insertions, 0 deletions