Rename {i,u}N::*exact_div to *div_exact
This commit is contained in:
parent
73e6c9ebd9
commit
b76267672f
4 changed files with 66 additions and 66 deletions
|
|
@ -992,10 +992,10 @@ macro_rules! int_impl {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(exact_div)]
|
||||
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_exact_div(-1), Some(", stringify!($Max), "));")]
|
||||
#[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").checked_exact_div(2), None);")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_exact_div(-1), None);")]
|
||||
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_exact_div(0), None);")]
|
||||
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_div_exact(-1), Some(", stringify!($Max), "));")]
|
||||
#[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").checked_div_exact(2), None);")]
|
||||
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_div_exact(-1), None);")]
|
||||
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div_exact(0), None);")]
|
||||
/// ```
|
||||
#[unstable(
|
||||
feature = "exact_div",
|
||||
|
|
@ -1004,7 +1004,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const fn checked_exact_div(self, rhs: Self) -> Option<Self> {
|
||||
pub const fn checked_div_exact(self, rhs: Self) -> Option<Self> {
|
||||
if intrinsics::unlikely(rhs == 0 || ((self == Self::MIN) && (rhs == -1))) {
|
||||
None
|
||||
} else {
|
||||
|
|
@ -1034,18 +1034,18 @@ macro_rules! int_impl {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(exact_div)]
|
||||
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), Some(32));")]
|
||||
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(32), Some(2));")]
|
||||
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).exact_div(-1), Some(", stringify!($Max), "));")]
|
||||
#[doc = concat!("assert_eq!(65", stringify!($SelfT), ".exact_div(2), None);")]
|
||||
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".div_exact(2), Some(32));")]
|
||||
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".div_exact(32), Some(2));")]
|
||||
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).div_exact(-1), Some(", stringify!($Max), "));")]
|
||||
#[doc = concat!("assert_eq!(65", stringify!($SelfT), ".div_exact(2), None);")]
|
||||
/// ```
|
||||
/// ```should_panic
|
||||
/// #![feature(exact_div)]
|
||||
#[doc = concat!("let _ = 64", stringify!($SelfT),".exact_div(0);")]
|
||||
#[doc = concat!("let _ = 64", stringify!($SelfT),".div_exact(0);")]
|
||||
/// ```
|
||||
/// ```should_panic
|
||||
/// #![feature(exact_div)]
|
||||
#[doc = concat!("let _ = ", stringify!($SelfT), "::MIN.exact_div(-1);")]
|
||||
#[doc = concat!("let _ = ", stringify!($SelfT), "::MIN.div_exact(-1);")]
|
||||
/// ```
|
||||
#[unstable(
|
||||
feature = "exact_div",
|
||||
|
|
@ -1055,7 +1055,7 @@ macro_rules! int_impl {
|
|||
without modifying the original"]
|
||||
#[inline]
|
||||
#[rustc_inherit_overflow_checks]
|
||||
pub const fn exact_div(self, rhs: Self) -> Option<Self> {
|
||||
pub const fn div_exact(self, rhs: Self) -> Option<Self> {
|
||||
if self % rhs != 0 {
|
||||
None
|
||||
} else {
|
||||
|
|
@ -1069,7 +1069,7 @@ macro_rules! int_impl {
|
|||
///
|
||||
/// This results in undefined behavior when `rhs == 0`, `self % rhs != 0`, or
|
||||
#[doc = concat!("`self == ", stringify!($SelfT), "::MIN && rhs == -1`,")]
|
||||
/// i.e. when [`checked_exact_div`](Self::checked_exact_div) would return `None`.
|
||||
/// i.e. when [`checked_div_exact`](Self::checked_div_exact) would return `None`.
|
||||
#[unstable(
|
||||
feature = "exact_div",
|
||||
issue = "139911",
|
||||
|
|
@ -1077,10 +1077,10 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
pub const unsafe fn unchecked_exact_div(self, rhs: Self) -> Self {
|
||||
pub const unsafe fn unchecked_div_exact(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
concat!(stringify!($SelfT), "::unchecked_exact_div cannot overflow, divide by zero, or leave a remainder"),
|
||||
concat!(stringify!($SelfT), "::unchecked_div_exact cannot overflow, divide by zero, or leave a remainder"),
|
||||
(
|
||||
lhs: $SelfT = self,
|
||||
rhs: $SelfT = rhs,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue