Rollup merge of #144971 - okaneco:rename_isolate_ones, r=joshtriplett

num: Rename `isolate_most_least_significant_one` functions

Tracking issue - https://github.com/rust-lang/rust/issues/136909

libs-api has agreed to rename these unstable functions to `isolate_highest_one`/`isolate_lowest_one`
https://github.com/rust-lang/rust/issues/136909#issuecomment-3156005820

`isolate_most_significant_one` -> `isolate_highest_one`
`isolate_least_significant_one` -> `isolate_lowest_one`
This commit is contained in:
Jakub Beránek
2025-08-06 15:55:48 +02:00
committed by GitHub
6 changed files with 38 additions and 38 deletions

View File

@@ -177,14 +177,14 @@ macro_rules! int_impl {
/// ///
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
/// ///
/// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); /// assert_eq!(n.isolate_highest_one(), 0b_01000000);
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_highest_one(), 0);")]
/// ``` /// ```
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[inline(always)] #[inline(always)]
pub const fn isolate_most_significant_one(self) -> Self { pub const fn isolate_highest_one(self) -> Self {
self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros()))
} }
@@ -198,14 +198,14 @@ macro_rules! int_impl {
/// ///
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
/// ///
/// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); /// assert_eq!(n.isolate_lowest_one(), 0b_00000100);
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_lowest_one(), 0);")]
/// ``` /// ```
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[inline(always)] #[inline(always)]
pub const fn isolate_least_significant_one(self) -> Self { pub const fn isolate_lowest_one(self) -> Self {
self & self.wrapping_neg() self & self.wrapping_neg()
} }

View File

@@ -629,7 +629,7 @@ macro_rules! nonzero_integer {
#[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")]
#[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_01000000)?;")] #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_01000000)?;")]
/// ///
/// assert_eq!(a.isolate_most_significant_one(), b); /// assert_eq!(a.isolate_highest_one(), b);
/// # Some(()) /// # Some(())
/// # } /// # }
/// ``` /// ```
@@ -637,7 +637,7 @@ macro_rules! nonzero_integer {
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[inline(always)] #[inline(always)]
pub const fn isolate_most_significant_one(self) -> Self { pub const fn isolate_highest_one(self) -> Self {
let n = self.get() & (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros())); let n = self.get() & (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros()));
// SAFETY: // SAFETY:
@@ -659,7 +659,7 @@ macro_rules! nonzero_integer {
#[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")]
#[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_00000100)?;")] #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_00000100)?;")]
/// ///
/// assert_eq!(a.isolate_least_significant_one(), b); /// assert_eq!(a.isolate_lowest_one(), b);
/// # Some(()) /// # Some(())
/// # } /// # }
/// ``` /// ```
@@ -667,7 +667,7 @@ macro_rules! nonzero_integer {
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[inline(always)] #[inline(always)]
pub const fn isolate_least_significant_one(self) -> Self { pub const fn isolate_lowest_one(self) -> Self {
let n = self.get(); let n = self.get();
let n = n & n.wrapping_neg(); let n = n & n.wrapping_neg();

View File

@@ -229,14 +229,14 @@ macro_rules! uint_impl {
/// ///
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
/// ///
/// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); /// assert_eq!(n.isolate_highest_one(), 0b_01000000);
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_highest_one(), 0);")]
/// ``` /// ```
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[inline(always)] #[inline(always)]
pub const fn isolate_most_significant_one(self) -> Self { pub const fn isolate_highest_one(self) -> Self {
self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros()))
} }
@@ -250,14 +250,14 @@ macro_rules! uint_impl {
/// ///
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
/// ///
/// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); /// assert_eq!(n.isolate_lowest_one(), 0b_00000100);
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_lowest_one(), 0);")]
/// ``` /// ```
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
#[must_use = "this returns the result of the operation, \ #[must_use = "this returns the result of the operation, \
without modifying the original"] without modifying the original"]
#[inline(always)] #[inline(always)]
pub const fn isolate_least_significant_one(self) -> Self { pub const fn isolate_lowest_one(self) -> Self {
self & self.wrapping_neg() self & self.wrapping_neg()
} }

View File

@@ -321,7 +321,7 @@ fn nonzero_trailing_zeros() {
} }
#[test] #[test]
fn test_nonzero_isolate_most_significant_one() { fn test_nonzero_isolate_highest_one() {
// Signed most significant one // Signed most significant one
macro_rules! nonzero_int_impl { macro_rules! nonzero_int_impl {
($($T:ty),+) => { ($($T:ty),+) => {
@@ -335,8 +335,8 @@ fn test_nonzero_isolate_most_significant_one() {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), NonZero::<$T>::new(BITS >> i).unwrap().isolate_highest_one(),
NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one() NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_highest_one()
); );
i += 1; i += 1;
} }
@@ -356,8 +356,8 @@ fn test_nonzero_isolate_most_significant_one() {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), NonZero::<$T>::new(BITS >> i).unwrap().isolate_highest_one(),
NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one(), NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_highest_one(),
); );
i += 1; i += 1;
} }
@@ -371,7 +371,7 @@ fn test_nonzero_isolate_most_significant_one() {
} }
#[test] #[test]
fn test_nonzero_isolate_least_significant_one() { fn test_nonzero_isolate_lowest_one() {
// Signed least significant one // Signed least significant one
macro_rules! nonzero_int_impl { macro_rules! nonzero_int_impl {
($($T:ty),+) => { ($($T:ty),+) => {
@@ -385,8 +385,8 @@ fn test_nonzero_isolate_least_significant_one() {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), NonZero::<$T>::new(BITS << i).unwrap().isolate_lowest_one(),
NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one() NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_lowest_one()
); );
i += 1; i += 1;
} }
@@ -406,8 +406,8 @@ fn test_nonzero_isolate_least_significant_one() {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), NonZero::<$T>::new(BITS << i).unwrap().isolate_lowest_one(),
NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one(), NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_lowest_one(),
); );
i += 1; i += 1;
} }

View File

@@ -194,7 +194,7 @@ macro_rules! int_module {
} }
#[test] #[test]
fn test_isolate_most_significant_one() { fn test_isolate_highest_one() {
const BITS: $T = -1; const BITS: $T = -1;
const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1);
@@ -203,15 +203,15 @@ macro_rules! int_module {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
(BITS >> i).isolate_most_significant_one(), (BITS >> i).isolate_highest_one(),
(MOST_SIG_ONE >> i).isolate_most_significant_one() (MOST_SIG_ONE >> i).isolate_highest_one()
); );
i += 1; i += 1;
} }
} }
#[test] #[test]
fn test_isolate_least_significant_one() { fn test_isolate_lowest_one() {
const BITS: $T = -1; const BITS: $T = -1;
const LEAST_SIG_ONE: $T = 1; const LEAST_SIG_ONE: $T = 1;
@@ -220,8 +220,8 @@ macro_rules! int_module {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
(BITS << i).isolate_least_significant_one(), (BITS << i).isolate_lowest_one(),
(LEAST_SIG_ONE << i).isolate_least_significant_one() (LEAST_SIG_ONE << i).isolate_lowest_one()
); );
i += 1; i += 1;
} }

View File

@@ -151,7 +151,7 @@ macro_rules! uint_module {
} }
#[test] #[test]
fn test_isolate_most_significant_one() { fn test_isolate_highest_one() {
const BITS: $T = <$T>::MAX; const BITS: $T = <$T>::MAX;
const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1);
@@ -160,15 +160,15 @@ macro_rules! uint_module {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
(BITS >> i).isolate_most_significant_one(), (BITS >> i).isolate_highest_one(),
(MOST_SIG_ONE >> i).isolate_most_significant_one(), (MOST_SIG_ONE >> i).isolate_highest_one(),
); );
i += 1; i += 1;
} }
} }
#[test] #[test]
fn test_isolate_least_significant_one() { fn test_isolate_lowest_one() {
const BITS: $T = <$T>::MAX; const BITS: $T = <$T>::MAX;
const LEAST_SIG_ONE: $T = 1; const LEAST_SIG_ONE: $T = 1;
@@ -177,8 +177,8 @@ macro_rules! uint_module {
let mut i = 0; let mut i = 0;
while i < <$T>::BITS { while i < <$T>::BITS {
assert_eq!( assert_eq!(
(BITS << i).isolate_least_significant_one(), (BITS << i).isolate_lowest_one(),
(LEAST_SIG_ONE << i).isolate_least_significant_one(), (LEAST_SIG_ONE << i).isolate_lowest_one(),
); );
i += 1; i += 1;
} }