Skip to content

Commit f590ae6

Browse files
committed
Rename {u,i}N::*exact_sh{l,r} to *sh{l,r}_exact
1 parent b762676 commit f590ae6

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

library/core/src/num/int_macros.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,17 +1431,17 @@ macro_rules! int_impl {
14311431
/// ```
14321432
/// #![feature(exact_bitshifts)]
14331433
///
1434-
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(4), Some(0x10));")]
1435-
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(", stringify!($SelfT), "::BITS - 2), Some(1 << ", stringify!($SelfT), "::BITS - 2));")]
1436-
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(", stringify!($SelfT), "::BITS - 1), None);")]
1437-
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").exact_shl(", stringify!($SelfT), "::BITS - 2), Some(-0x2 << ", stringify!($SelfT), "::BITS - 2));")]
1438-
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").exact_shl(", stringify!($SelfT), "::BITS - 1), None);")]
1434+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(4), Some(0x10));")]
1435+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(", stringify!($SelfT), "::BITS - 2), Some(1 << ", stringify!($SelfT), "::BITS - 2));")]
1436+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(", stringify!($SelfT), "::BITS - 1), None);")]
1437+
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").shl_exact(", stringify!($SelfT), "::BITS - 2), Some(-0x2 << ", stringify!($SelfT), "::BITS - 2));")]
1438+
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").shl_exact(", stringify!($SelfT), "::BITS - 1), None);")]
14391439
/// ```
14401440
#[unstable(feature = "exact_bitshifts", issue = "144336")]
14411441
#[must_use = "this returns the result of the operation, \
14421442
without modifying the original"]
14431443
#[inline]
1444-
pub const fn exact_shl(self, rhs: u32) -> Option<$SelfT> {
1444+
pub const fn shl_exact(self, rhs: u32) -> Option<$SelfT> {
14451445
if rhs < self.leading_zeros() || rhs < self.leading_ones() {
14461446
// SAFETY: rhs is checked above
14471447
Some(unsafe { self.unchecked_shl(rhs) })
@@ -1458,16 +1458,16 @@ macro_rules! int_impl {
14581458
///
14591459
/// This results in undefined behavior when `rhs >= self.leading_zeros() && rhs >=
14601460
/// self.leading_ones()` i.e. when
1461-
#[doc = concat!("[`", stringify!($SelfT), "::exact_shl`]")]
1461+
#[doc = concat!("[`", stringify!($SelfT), "::shl_exact`]")]
14621462
/// would return `None`.
14631463
#[unstable(feature = "exact_bitshifts", issue = "144336")]
14641464
#[must_use = "this returns the result of the operation, \
14651465
without modifying the original"]
14661466
#[inline]
1467-
pub const unsafe fn unchecked_exact_shl(self, rhs: u32) -> $SelfT {
1467+
pub const unsafe fn unchecked_shl_exact(self, rhs: u32) -> $SelfT {
14681468
assert_unsafe_precondition!(
14691469
check_library_ub,
1470-
concat!(stringify!($SelfT), "::unchecked_exact_shl cannot shift out bits that would change the value of the first bit"),
1470+
concat!(stringify!($SelfT), "::unchecked_shl_exact cannot shift out bits that would change the value of the first bit"),
14711471
(
14721472
zeros: u32 = self.leading_zeros(),
14731473
ones: u32 = self.leading_ones(),
@@ -1611,14 +1611,14 @@ macro_rules! int_impl {
16111611
/// ```
16121612
/// #![feature(exact_bitshifts)]
16131613
///
1614-
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(4), Some(0x1));")]
1615-
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(5), None);")]
1614+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(4), Some(0x1));")]
1615+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(5), None);")]
16161616
/// ```
16171617
#[unstable(feature = "exact_bitshifts", issue = "144336")]
16181618
#[must_use = "this returns the result of the operation, \
16191619
without modifying the original"]
16201620
#[inline]
1621-
pub const fn exact_shr(self, rhs: u32) -> Option<$SelfT> {
1621+
pub const fn shr_exact(self, rhs: u32) -> Option<$SelfT> {
16221622
if rhs <= self.trailing_zeros() && rhs < <$SelfT>::BITS {
16231623
// SAFETY: rhs is checked above
16241624
Some(unsafe { self.unchecked_shr(rhs) })
@@ -1636,16 +1636,16 @@ macro_rules! int_impl {
16361636
/// This results in undefined behavior when `rhs > self.trailing_zeros() || rhs >=
16371637
#[doc = concat!(stringify!($SelfT), "::BITS`")]
16381638
/// i.e. when
1639-
#[doc = concat!("[`", stringify!($SelfT), "::exact_shr`]")]
1639+
#[doc = concat!("[`", stringify!($SelfT), "::shr_exact`]")]
16401640
/// would return `None`.
16411641
#[unstable(feature = "exact_bitshifts", issue = "144336")]
16421642
#[must_use = "this returns the result of the operation, \
16431643
without modifying the original"]
16441644
#[inline]
1645-
pub const unsafe fn unchecked_exact_shr(self, rhs: u32) -> $SelfT {
1645+
pub const unsafe fn unchecked_shr_exact(self, rhs: u32) -> $SelfT {
16461646
assert_unsafe_precondition!(
16471647
check_library_ub,
1648-
concat!(stringify!($SelfT), "::unchecked_exact_shr cannot shift out non-zero bits"),
1648+
concat!(stringify!($SelfT), "::unchecked_shr_exact cannot shift out non-zero bits"),
16491649
(
16501650
zeros: u32 = self.trailing_zeros(),
16511651
bits: u32 = <$SelfT>::BITS,

library/core/src/num/uint_macros.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,14 +1830,14 @@ macro_rules! uint_impl {
18301830
/// ```
18311831
/// #![feature(exact_bitshifts)]
18321832
///
1833-
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(4), Some(0x10));")]
1834-
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(129), None);")]
1833+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(4), Some(0x10));")]
1834+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(129), None);")]
18351835
/// ```
18361836
#[unstable(feature = "exact_bitshifts", issue = "144336")]
18371837
#[must_use = "this returns the result of the operation, \
18381838
without modifying the original"]
18391839
#[inline]
1840-
pub const fn exact_shl(self, rhs: u32) -> Option<$SelfT> {
1840+
pub const fn shl_exact(self, rhs: u32) -> Option<$SelfT> {
18411841
if rhs <= self.leading_zeros() && rhs < <$SelfT>::BITS {
18421842
// SAFETY: rhs is checked above
18431843
Some(unsafe { self.unchecked_shl(rhs) })
@@ -1855,16 +1855,16 @@ macro_rules! uint_impl {
18551855
/// This results in undefined behavior when `rhs > self.leading_zeros() || rhs >=
18561856
#[doc = concat!(stringify!($SelfT), "::BITS`")]
18571857
/// i.e. when
1858-
#[doc = concat!("[`", stringify!($SelfT), "::exact_shl`]")]
1858+
#[doc = concat!("[`", stringify!($SelfT), "::shl_exact`]")]
18591859
/// would return `None`.
18601860
#[unstable(feature = "exact_bitshifts", issue = "144336")]
18611861
#[must_use = "this returns the result of the operation, \
18621862
without modifying the original"]
18631863
#[inline]
1864-
pub const unsafe fn unchecked_exact_shl(self, rhs: u32) -> $SelfT {
1864+
pub const unsafe fn unchecked_shl_exact(self, rhs: u32) -> $SelfT {
18651865
assert_unsafe_precondition!(
18661866
check_library_ub,
1867-
concat!(stringify!($SelfT), "::exact_shl_unchecked cannot shift out non-zero bits"),
1867+
concat!(stringify!($SelfT), "::unchecked_shl_exact cannot shift out non-zero bits"),
18681868
(
18691869
zeros: u32 = self.leading_zeros(),
18701870
bits: u32 = <$SelfT>::BITS,
@@ -2002,14 +2002,14 @@ macro_rules! uint_impl {
20022002
/// ```
20032003
/// #![feature(exact_bitshifts)]
20042004
///
2005-
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(4), Some(0x1));")]
2006-
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(5), None);")]
2005+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(4), Some(0x1));")]
2006+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(5), None);")]
20072007
/// ```
20082008
#[unstable(feature = "exact_bitshifts", issue = "144336")]
20092009
#[must_use = "this returns the result of the operation, \
20102010
without modifying the original"]
20112011
#[inline]
2012-
pub const fn exact_shr(self, rhs: u32) -> Option<$SelfT> {
2012+
pub const fn shr_exact(self, rhs: u32) -> Option<$SelfT> {
20132013
if rhs <= self.trailing_zeros() && rhs < <$SelfT>::BITS {
20142014
// SAFETY: rhs is checked above
20152015
Some(unsafe { self.unchecked_shr(rhs) })
@@ -2027,16 +2027,16 @@ macro_rules! uint_impl {
20272027
/// This results in undefined behavior when `rhs > self.trailing_zeros() || rhs >=
20282028
#[doc = concat!(stringify!($SelfT), "::BITS`")]
20292029
/// i.e. when
2030-
#[doc = concat!("[`", stringify!($SelfT), "::exact_shr`]")]
2030+
#[doc = concat!("[`", stringify!($SelfT), "::shr_exact`]")]
20312031
/// would return `None`.
20322032
#[unstable(feature = "exact_bitshifts", issue = "144336")]
20332033
#[must_use = "this returns the result of the operation, \
20342034
without modifying the original"]
20352035
#[inline]
2036-
pub const unsafe fn unchecked_exact_shr(self, rhs: u32) -> $SelfT {
2036+
pub const unsafe fn unchecked_shr_exact(self, rhs: u32) -> $SelfT {
20372037
assert_unsafe_precondition!(
20382038
check_library_ub,
2039-
concat!(stringify!($SelfT), "::exact_shr_unchecked cannot shift out non-zero bits"),
2039+
concat!(stringify!($SelfT), "::unchecked_shr_exact cannot shift out non-zero bits"),
20402040
(
20412041
zeros: u32 = self.trailing_zeros(),
20422042
bits: u32 = <$SelfT>::BITS,

0 commit comments

Comments
 (0)