Rename {u,i}N::*exact_sh{l,r} to *sh{l,r}_exact
This commit is contained in:
parent
b76267672f
commit
f590ae6543
2 changed files with 27 additions and 27 deletions
|
|
@ -1431,17 +1431,17 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
/// #![feature(exact_bitshifts)]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(4), Some(0x10));")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(", stringify!($SelfT), "::BITS - 2), Some(1 << ", stringify!($SelfT), "::BITS - 2));")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(", stringify!($SelfT), "::BITS - 1), None);")]
|
||||
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").exact_shl(", stringify!($SelfT), "::BITS - 2), Some(-0x2 << ", stringify!($SelfT), "::BITS - 2));")]
|
||||
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").exact_shl(", stringify!($SelfT), "::BITS - 1), None);")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(4), Some(0x10));")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(", stringify!($SelfT), "::BITS - 2), Some(1 << ", stringify!($SelfT), "::BITS - 2));")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(", stringify!($SelfT), "::BITS - 1), None);")]
|
||||
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").shl_exact(", stringify!($SelfT), "::BITS - 2), Some(-0x2 << ", stringify!($SelfT), "::BITS - 2));")]
|
||||
#[doc = concat!("assert_eq!((-0x2", stringify!($SelfT), ").shl_exact(", stringify!($SelfT), "::BITS - 1), None);")]
|
||||
/// ```
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn exact_shl(self, rhs: u32) -> Option<$SelfT> {
|
||||
pub const fn shl_exact(self, rhs: u32) -> Option<$SelfT> {
|
||||
if rhs < self.leading_zeros() || rhs < self.leading_ones() {
|
||||
// SAFETY: rhs is checked above
|
||||
Some(unsafe { self.unchecked_shl(rhs) })
|
||||
|
|
@ -1458,16 +1458,16 @@ macro_rules! int_impl {
|
|||
///
|
||||
/// This results in undefined behavior when `rhs >= self.leading_zeros() && rhs >=
|
||||
/// self.leading_ones()` i.e. when
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::exact_shl`]")]
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::shl_exact`]")]
|
||||
/// would return `None`.
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_exact_shl(self, rhs: u32) -> $SelfT {
|
||||
pub const unsafe fn unchecked_shl_exact(self, rhs: u32) -> $SelfT {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
concat!(stringify!($SelfT), "::unchecked_exact_shl cannot shift out bits that would change the value of the first bit"),
|
||||
concat!(stringify!($SelfT), "::unchecked_shl_exact cannot shift out bits that would change the value of the first bit"),
|
||||
(
|
||||
zeros: u32 = self.leading_zeros(),
|
||||
ones: u32 = self.leading_ones(),
|
||||
|
|
@ -1611,14 +1611,14 @@ macro_rules! int_impl {
|
|||
/// ```
|
||||
/// #![feature(exact_bitshifts)]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(4), Some(0x1));")]
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(5), None);")]
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(4), Some(0x1));")]
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(5), None);")]
|
||||
/// ```
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn exact_shr(self, rhs: u32) -> Option<$SelfT> {
|
||||
pub const fn shr_exact(self, rhs: u32) -> Option<$SelfT> {
|
||||
if rhs <= self.trailing_zeros() && rhs < <$SelfT>::BITS {
|
||||
// SAFETY: rhs is checked above
|
||||
Some(unsafe { self.unchecked_shr(rhs) })
|
||||
|
|
@ -1636,16 +1636,16 @@ macro_rules! int_impl {
|
|||
/// This results in undefined behavior when `rhs > self.trailing_zeros() || rhs >=
|
||||
#[doc = concat!(stringify!($SelfT), "::BITS`")]
|
||||
/// i.e. when
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::exact_shr`]")]
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::shr_exact`]")]
|
||||
/// would return `None`.
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_exact_shr(self, rhs: u32) -> $SelfT {
|
||||
pub const unsafe fn unchecked_shr_exact(self, rhs: u32) -> $SelfT {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
concat!(stringify!($SelfT), "::unchecked_exact_shr cannot shift out non-zero bits"),
|
||||
concat!(stringify!($SelfT), "::unchecked_shr_exact cannot shift out non-zero bits"),
|
||||
(
|
||||
zeros: u32 = self.trailing_zeros(),
|
||||
bits: u32 = <$SelfT>::BITS,
|
||||
|
|
|
|||
|
|
@ -1830,14 +1830,14 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
/// #![feature(exact_bitshifts)]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(4), Some(0x10));")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".exact_shl(129), None);")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(4), Some(0x10));")]
|
||||
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".shl_exact(129), None);")]
|
||||
/// ```
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn exact_shl(self, rhs: u32) -> Option<$SelfT> {
|
||||
pub const fn shl_exact(self, rhs: u32) -> Option<$SelfT> {
|
||||
if rhs <= self.leading_zeros() && rhs < <$SelfT>::BITS {
|
||||
// SAFETY: rhs is checked above
|
||||
Some(unsafe { self.unchecked_shl(rhs) })
|
||||
|
|
@ -1855,16 +1855,16 @@ macro_rules! uint_impl {
|
|||
/// This results in undefined behavior when `rhs > self.leading_zeros() || rhs >=
|
||||
#[doc = concat!(stringify!($SelfT), "::BITS`")]
|
||||
/// i.e. when
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::exact_shl`]")]
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::shl_exact`]")]
|
||||
/// would return `None`.
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_exact_shl(self, rhs: u32) -> $SelfT {
|
||||
pub const unsafe fn unchecked_shl_exact(self, rhs: u32) -> $SelfT {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
concat!(stringify!($SelfT), "::exact_shl_unchecked cannot shift out non-zero bits"),
|
||||
concat!(stringify!($SelfT), "::unchecked_shl_exact cannot shift out non-zero bits"),
|
||||
(
|
||||
zeros: u32 = self.leading_zeros(),
|
||||
bits: u32 = <$SelfT>::BITS,
|
||||
|
|
@ -2002,14 +2002,14 @@ macro_rules! uint_impl {
|
|||
/// ```
|
||||
/// #![feature(exact_bitshifts)]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(4), Some(0x1));")]
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".exact_shr(5), None);")]
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(4), Some(0x1));")]
|
||||
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".shr_exact(5), None);")]
|
||||
/// ```
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn exact_shr(self, rhs: u32) -> Option<$SelfT> {
|
||||
pub const fn shr_exact(self, rhs: u32) -> Option<$SelfT> {
|
||||
if rhs <= self.trailing_zeros() && rhs < <$SelfT>::BITS {
|
||||
// SAFETY: rhs is checked above
|
||||
Some(unsafe { self.unchecked_shr(rhs) })
|
||||
|
|
@ -2027,16 +2027,16 @@ macro_rules! uint_impl {
|
|||
/// This results in undefined behavior when `rhs > self.trailing_zeros() || rhs >=
|
||||
#[doc = concat!(stringify!($SelfT), "::BITS`")]
|
||||
/// i.e. when
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::exact_shr`]")]
|
||||
#[doc = concat!("[`", stringify!($SelfT), "::shr_exact`]")]
|
||||
/// would return `None`.
|
||||
#[unstable(feature = "exact_bitshifts", issue = "144336")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_exact_shr(self, rhs: u32) -> $SelfT {
|
||||
pub const unsafe fn unchecked_shr_exact(self, rhs: u32) -> $SelfT {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
concat!(stringify!($SelfT), "::exact_shr_unchecked cannot shift out non-zero bits"),
|
||||
concat!(stringify!($SelfT), "::unchecked_shr_exact cannot shift out non-zero bits"),
|
||||
(
|
||||
zeros: u32 = self.trailing_zeros(),
|
||||
bits: u32 = <$SelfT>::BITS,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue