Skip to content

Commit 5704ebc

Browse files
committed
Rename {i,u}N::*exact_div to *div_exact
1 parent 402ce0e commit 5704ebc

File tree

4 files changed

+65
-65
lines changed

4 files changed

+65
-65
lines changed

library/core/src/num/int_macros.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,10 @@ macro_rules! int_impl {
992992
///
993993
/// ```
994994
/// #![feature(exact_div)]
995-
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_exact_div(-1), Some(", stringify!($Max), "));")]
996-
#[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").checked_exact_div(2), None);")]
997-
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_exact_div(-1), None);")]
998-
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_exact_div(0), None);")]
995+
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_div_exact(-1), Some(", stringify!($Max), "));")]
996+
#[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").checked_div_exact(2), None);")]
997+
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_div_exact(-1), None);")]
998+
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div_exact(0), None);")]
999999
/// ```
10001000
#[unstable(
10011001
feature = "exact_div",
@@ -1004,7 +1004,7 @@ macro_rules! int_impl {
10041004
#[must_use = "this returns the result of the operation, \
10051005
without modifying the original"]
10061006
#[inline]
1007-
pub const fn checked_exact_div(self, rhs: Self) -> Option<Self> {
1007+
pub const fn checked_div_exact(self, rhs: Self) -> Option<Self> {
10081008
if intrinsics::unlikely(rhs == 0 || ((self == Self::MIN) && (rhs == -1))) {
10091009
None
10101010
} else {
@@ -1030,18 +1030,18 @@ macro_rules! int_impl {
10301030
///
10311031
/// ```
10321032
/// #![feature(exact_div)]
1033-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")]
1034-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(32), 2);")]
1035-
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).exact_div(-1), ", stringify!($Max), ");")]
1033+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".div_exact(2), 32);")]
1034+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".div_exact(32), 2);")]
1035+
#[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).div_exact(-1), ", stringify!($Max), ");")]
10361036
/// ```
10371037
///
10381038
/// ```should_panic
10391039
/// #![feature(exact_div)]
1040-
#[doc = concat!("let _ = 65", stringify!($SelfT), ".exact_div(2);")]
1040+
#[doc = concat!("let _ = 65", stringify!($SelfT), ".div_exact(2);")]
10411041
/// ```
10421042
/// ```should_panic
10431043
/// #![feature(exact_div)]
1044-
#[doc = concat!("let _ = ", stringify!($SelfT), "::MIN.exact_div(-1);")]
1044+
#[doc = concat!("let _ = ", stringify!($SelfT), "::MIN.div_exact(-1);")]
10451045
/// ```
10461046
#[unstable(
10471047
feature = "exact_div",
@@ -1050,8 +1050,8 @@ macro_rules! int_impl {
10501050
#[must_use = "this returns the result of the operation, \
10511051
without modifying the original"]
10521052
#[inline]
1053-
pub const fn exact_div(self, rhs: Self) -> Self {
1054-
match self.checked_exact_div(rhs) {
1053+
pub const fn div_exact(self, rhs: Self) -> Self {
1054+
match self.checked_div_exact(rhs) {
10551055
Some(x) => x,
10561056
None => panic!("Failed to divide without remainder"),
10571057
}
@@ -1063,18 +1063,18 @@ macro_rules! int_impl {
10631063
///
10641064
/// This results in undefined behavior when `rhs == 0`, `self % rhs != 0`, or
10651065
#[doc = concat!("`self == ", stringify!($SelfT), "::MIN && rhs == -1`,")]
1066-
/// i.e. when [`checked_exact_div`](Self::checked_exact_div) would return `None`.
1066+
/// i.e. when [`checked_div_exact`](Self::checked_div_exact) would return `None`.
10671067
#[unstable(
10681068
feature = "exact_div",
10691069
issue = "139911",
10701070
)]
10711071
#[must_use = "this returns the result of the operation, \
10721072
without modifying the original"]
10731073
#[inline]
1074-
pub const unsafe fn unchecked_exact_div(self, rhs: Self) -> Self {
1074+
pub const unsafe fn unchecked_div_exact(self, rhs: Self) -> Self {
10751075
assert_unsafe_precondition!(
10761076
check_language_ub,
1077-
concat!(stringify!($SelfT), "::unchecked_exact_div cannot overflow, divide by zero, or leave a remainder"),
1077+
concat!(stringify!($SelfT), "::unchecked_div_exact cannot overflow, divide by zero, or leave a remainder"),
10781078
(
10791079
lhs: $SelfT = self,
10801080
rhs: $SelfT = rhs,

library/core/src/num/uint_macros.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,10 +1222,10 @@ macro_rules! uint_impl {
12221222
///
12231223
/// ```
12241224
/// #![feature(exact_div)]
1225-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(2), Some(32));")]
1226-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(32), Some(2));")]
1227-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(0), None);")]
1228-
#[doc = concat!("assert_eq!(65", stringify!($SelfT), ".checked_exact_div(2), None);")]
1225+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_div_exact(2), Some(32));")]
1226+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_div_exact(32), Some(2));")]
1227+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_div_exact(0), None);")]
1228+
#[doc = concat!("assert_eq!(65", stringify!($SelfT), ".checked_div_exact(2), None);")]
12291229
/// ```
12301230
#[unstable(
12311231
feature = "exact_div",
@@ -1234,7 +1234,7 @@ macro_rules! uint_impl {
12341234
#[must_use = "this returns the result of the operation, \
12351235
without modifying the original"]
12361236
#[inline]
1237-
pub const fn checked_exact_div(self, rhs: Self) -> Option<Self> {
1237+
pub const fn checked_div_exact(self, rhs: Self) -> Option<Self> {
12381238
if intrinsics::unlikely(rhs == 0) {
12391239
None
12401240
} else {
@@ -1259,13 +1259,13 @@ macro_rules! uint_impl {
12591259
///
12601260
/// ```
12611261
/// #![feature(exact_div)]
1262-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")]
1263-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(32), 2);")]
1262+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".div_exact(2), 32);")]
1263+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".div_exact(32), 2);")]
12641264
/// ```
12651265
///
12661266
/// ```should_panic
12671267
/// #![feature(exact_div)]
1268-
#[doc = concat!("let _ = 65", stringify!($SelfT), ".exact_div(2);")]
1268+
#[doc = concat!("let _ = 65", stringify!($SelfT), ".div_exact(2);")]
12691269
/// ```
12701270
#[unstable(
12711271
feature = "exact_div",
@@ -1274,8 +1274,8 @@ macro_rules! uint_impl {
12741274
#[must_use = "this returns the result of the operation, \
12751275
without modifying the original"]
12761276
#[inline]
1277-
pub const fn exact_div(self, rhs: Self) -> Self {
1278-
match self.checked_exact_div(rhs) {
1277+
pub const fn div_exact(self, rhs: Self) -> Self {
1278+
match self.checked_div_exact(rhs) {
12791279
Some(x) => x,
12801280
None => panic!("Failed to divide without remainder"),
12811281
}
@@ -1286,18 +1286,18 @@ macro_rules! uint_impl {
12861286
/// # Safety
12871287
///
12881288
/// This results in undefined behavior when `rhs == 0` or `self % rhs != 0`,
1289-
/// i.e. when [`checked_exact_div`](Self::checked_exact_div) would return `None`.
1289+
/// i.e. when [`checked_div_exact`](Self::checked_div_exact) would return `None`.
12901290
#[unstable(
12911291
feature = "exact_div",
12921292
issue = "139911",
12931293
)]
12941294
#[must_use = "this returns the result of the operation, \
12951295
without modifying the original"]
12961296
#[inline]
1297-
pub const unsafe fn unchecked_exact_div(self, rhs: Self) -> Self {
1297+
pub const unsafe fn unchecked_div_exact(self, rhs: Self) -> Self {
12981298
assert_unsafe_precondition!(
12991299
check_language_ub,
1300-
concat!(stringify!($SelfT), "::unchecked_exact_div divide by zero or leave a remainder"),
1300+
concat!(stringify!($SelfT), "::unchecked_div_exact divide by zero or leave a remainder"),
13011301
(
13021302
lhs: $SelfT = self,
13031303
rhs: $SelfT = rhs,

library/coretests/tests/num/int_macros.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -724,41 +724,41 @@ macro_rules! int_module {
724724
}
725725
}
726726

727-
const EXACT_DIV_SUCCESS_DIVIDEND1: $T = 42;
728-
const EXACT_DIV_SUCCESS_DIVISOR1: $T = 6;
729-
const EXACT_DIV_SUCCESS_QUOTIENT1: $T = 7;
730-
const EXACT_DIV_SUCCESS_DIVIDEND2: $T = 18;
731-
const EXACT_DIV_SUCCESS_DIVISOR2: $T = 3;
732-
const EXACT_DIV_SUCCESS_QUOTIENT2: $T = 6;
733-
const EXACT_DIV_SUCCESS_DIVIDEND3: $T = -91;
734-
const EXACT_DIV_SUCCESS_DIVISOR3: $T = 13;
735-
const EXACT_DIV_SUCCESS_QUOTIENT3: $T = -7;
736-
const EXACT_DIV_SUCCESS_DIVIDEND4: $T = -57;
737-
const EXACT_DIV_SUCCESS_DIVISOR4: $T = -3;
738-
const EXACT_DIV_SUCCESS_QUOTIENT4: $T = 19;
727+
const DIV_EXACT_SUCCESS_DIVIDEND1: $T = 42;
728+
const DIV_EXACT_SUCCESS_DIVISOR1: $T = 6;
729+
const DIV_EXACT_SUCCESS_QUOTIENT1: $T = 7;
730+
const DIV_EXACT_SUCCESS_DIVIDEND2: $T = 18;
731+
const DIV_EXACT_SUCCESS_DIVISOR2: $T = 3;
732+
const DIV_EXACT_SUCCESS_QUOTIENT2: $T = 6;
733+
const DIV_EXACT_SUCCESS_DIVIDEND3: $T = -91;
734+
const DIV_EXACT_SUCCESS_DIVISOR3: $T = 13;
735+
const DIV_EXACT_SUCCESS_QUOTIENT3: $T = -7;
736+
const DIV_EXACT_SUCCESS_DIVIDEND4: $T = -57;
737+
const DIV_EXACT_SUCCESS_DIVISOR4: $T = -3;
738+
const DIV_EXACT_SUCCESS_QUOTIENT4: $T = 19;
739739

740740
test_runtime_and_compiletime! {
741-
fn test_exact_div() {
741+
fn test_div_exact() {
742742
// 42 / 6
743-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), Some(EXACT_DIV_SUCCESS_QUOTIENT1));
744-
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), EXACT_DIV_SUCCESS_QUOTIENT1);
743+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(DIV_EXACT_SUCCESS_DIVIDEND1, DIV_EXACT_SUCCESS_DIVISOR1), Some(DIV_EXACT_SUCCESS_QUOTIENT1));
744+
assert_eq_const_safe!($T: <$T>::div_exact(DIV_EXACT_SUCCESS_DIVIDEND1, DIV_EXACT_SUCCESS_DIVISOR1), DIV_EXACT_SUCCESS_QUOTIENT1);
745745

746746
// 18 / 3
747-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), Some(EXACT_DIV_SUCCESS_QUOTIENT2));
748-
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), EXACT_DIV_SUCCESS_QUOTIENT2);
747+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(DIV_EXACT_SUCCESS_DIVIDEND2, DIV_EXACT_SUCCESS_DIVISOR2), Some(DIV_EXACT_SUCCESS_QUOTIENT2));
748+
assert_eq_const_safe!($T: <$T>::div_exact(DIV_EXACT_SUCCESS_DIVIDEND2, DIV_EXACT_SUCCESS_DIVISOR2), DIV_EXACT_SUCCESS_QUOTIENT2);
749749

750750
// -91 / 13
751-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND3, EXACT_DIV_SUCCESS_DIVISOR3), Some(EXACT_DIV_SUCCESS_QUOTIENT3));
752-
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND3, EXACT_DIV_SUCCESS_DIVISOR3), EXACT_DIV_SUCCESS_QUOTIENT3);
751+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(DIV_EXACT_SUCCESS_DIVIDEND3, DIV_EXACT_SUCCESS_DIVISOR3), Some(DIV_EXACT_SUCCESS_QUOTIENT3));
752+
assert_eq_const_safe!($T: <$T>::div_exact(DIV_EXACT_SUCCESS_DIVIDEND3, DIV_EXACT_SUCCESS_DIVISOR3), DIV_EXACT_SUCCESS_QUOTIENT3);
753753

754754
// -57 / -3
755-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND4, EXACT_DIV_SUCCESS_DIVISOR4), Some(EXACT_DIV_SUCCESS_QUOTIENT4));
756-
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND4, EXACT_DIV_SUCCESS_DIVISOR4), EXACT_DIV_SUCCESS_QUOTIENT4);
755+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(DIV_EXACT_SUCCESS_DIVIDEND4, DIV_EXACT_SUCCESS_DIVISOR4), Some(DIV_EXACT_SUCCESS_QUOTIENT4));
756+
assert_eq_const_safe!($T: <$T>::div_exact(DIV_EXACT_SUCCESS_DIVIDEND4, DIV_EXACT_SUCCESS_DIVISOR4), DIV_EXACT_SUCCESS_QUOTIENT4);
757757

758758
// failures
759-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(1, 2), None);
760-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(<$T>::MIN, -1), None);
761-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(0, 0), None);
759+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(1, 2), None);
760+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(<$T>::MIN, -1), None);
761+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(0, 0), None);
762762
}
763763
}
764764
};

library/coretests/tests/num/uint_macros.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -595,26 +595,26 @@ macro_rules! uint_module {
595595
}
596596
}
597597

598-
const EXACT_DIV_SUCCESS_DIVIDEND1: $T = 42;
599-
const EXACT_DIV_SUCCESS_DIVISOR1: $T = 6;
600-
const EXACT_DIV_SUCCESS_QUOTIENT1: $T = 7;
601-
const EXACT_DIV_SUCCESS_DIVIDEND2: $T = 18;
602-
const EXACT_DIV_SUCCESS_DIVISOR2: $T = 3;
603-
const EXACT_DIV_SUCCESS_QUOTIENT2: $T = 6;
598+
const DIV_EXACT_SUCCESS_DIVIDEND1: $T = 42;
599+
const DIV_EXACT_SUCCESS_DIVISOR1: $T = 6;
600+
const DIV_EXACT_SUCCESS_QUOTIENT1: $T = 7;
601+
const DIV_EXACT_SUCCESS_DIVIDEND2: $T = 18;
602+
const DIV_EXACT_SUCCESS_DIVISOR2: $T = 3;
603+
const DIV_EXACT_SUCCESS_QUOTIENT2: $T = 6;
604604

605605
test_runtime_and_compiletime! {
606-
fn test_exact_div() {
606+
fn test_div_exact() {
607607
// 42 / 6
608-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), Some(EXACT_DIV_SUCCESS_QUOTIENT1));
609-
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND1, EXACT_DIV_SUCCESS_DIVISOR1), EXACT_DIV_SUCCESS_QUOTIENT1);
608+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(DIV_EXACT_SUCCESS_DIVIDEND1, DIV_EXACT_SUCCESS_DIVISOR1), Some(DIV_EXACT_SUCCESS_QUOTIENT1));
609+
assert_eq_const_safe!($T: <$T>::div_exact(DIV_EXACT_SUCCESS_DIVIDEND1, DIV_EXACT_SUCCESS_DIVISOR1), DIV_EXACT_SUCCESS_QUOTIENT1);
610610

611611
// 18 / 3
612-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), Some(EXACT_DIV_SUCCESS_QUOTIENT2));
613-
assert_eq_const_safe!($T: <$T>::exact_div(EXACT_DIV_SUCCESS_DIVIDEND2, EXACT_DIV_SUCCESS_DIVISOR2), EXACT_DIV_SUCCESS_QUOTIENT2);
612+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(DIV_EXACT_SUCCESS_DIVIDEND2, DIV_EXACT_SUCCESS_DIVISOR2), Some(DIV_EXACT_SUCCESS_QUOTIENT2));
613+
assert_eq_const_safe!($T: <$T>::div_exact(DIV_EXACT_SUCCESS_DIVIDEND2, DIV_EXACT_SUCCESS_DIVISOR2), DIV_EXACT_SUCCESS_QUOTIENT2);
614614

615615
// failures
616-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(1, 2), None);
617-
assert_eq_const_safe!(Option<$T>: <$T>::checked_exact_div(0, 0), None);
616+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(1, 2), None);
617+
assert_eq_const_safe!(Option<$T>: <$T>::checked_div_exact(0, 0), None);
618618
}
619619
}
620620
};

0 commit comments

Comments
 (0)