Skip to content

Commit 5e17f31

Browse files
committed
Replace min/max_value() with MIN/MAX in integer docs
1 parent cf255c6 commit 5e17f31

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

src/libcore/num/mod.rs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ $EndFeature, "
336336
Basic usage:
337337
338338
```
339-
", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 1);", $EndFeature, "
339+
", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 1);", $EndFeature, "
340340
```"),
341341
#[stable(feature = "rust1", since = "1.0.0")]
342342
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
@@ -673,8 +673,8 @@ Basic usage:
673673
674674
```
675675
", $Feature, "assert_eq!((", stringify!($SelfT),
676-
"::max_value() - 2).checked_add(1), Some(", stringify!($SelfT), "::max_value() - 1));
677-
assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);",
676+
"::MAX - 2).checked_add(1), Some(", stringify!($SelfT), "::MAX - 1));
677+
assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);",
678678
$EndFeature, "
679679
```"),
680680
#[stable(feature = "rust1", since = "1.0.0")]
@@ -698,8 +698,8 @@ Basic usage:
698698
699699
```
700700
", $Feature, "assert_eq!((", stringify!($SelfT),
701-
"::min_value() + 2).checked_sub(1), Some(", stringify!($SelfT), "::min_value() + 1));
702-
assert_eq!((", stringify!($SelfT), "::min_value() + 2).checked_sub(3), None);",
701+
"::MIN + 2).checked_sub(1), Some(", stringify!($SelfT), "::MIN + 1));
702+
assert_eq!((", stringify!($SelfT), "::MIN + 2).checked_sub(3), None);",
703703
$EndFeature, "
704704
```"),
705705
#[stable(feature = "rust1", since = "1.0.0")]
@@ -723,8 +723,8 @@ Basic usage:
723723
724724
```
725725
", $Feature, "assert_eq!(", stringify!($SelfT),
726-
"::max_value().checked_mul(1), Some(", stringify!($SelfT), "::max_value()));
727-
assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);",
726+
"::MAX.checked_mul(1), Some(", stringify!($SelfT), "::MAX));
727+
assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);",
728728
$EndFeature, "
729729
```"),
730730
#[stable(feature = "rust1", since = "1.0.0")]
@@ -748,8 +748,8 @@ Basic usage:
748748
749749
```
750750
", $Feature, "assert_eq!((", stringify!($SelfT),
751-
"::min_value() + 1).checked_div(-1), Some(", stringify!($Max), "));
752-
assert_eq!(", stringify!($SelfT), "::min_value().checked_div(-1), None);
751+
"::MIN + 1).checked_div(-1), Some(", stringify!($Max), "));
752+
assert_eq!(", stringify!($SelfT), "::MIN.checked_div(-1), None);
753753
assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);",
754754
$EndFeature, "
755755
```"),
@@ -778,8 +778,8 @@ Basic usage:
778778
779779
```
780780
assert_eq!((", stringify!($SelfT),
781-
"::min_value() + 1).checked_div_euclid(-1), Some(", stringify!($Max), "));
782-
assert_eq!(", stringify!($SelfT), "::min_value().checked_div_euclid(-1), None);
781+
"::MIN + 1).checked_div_euclid(-1), Some(", stringify!($Max), "));
782+
assert_eq!(", stringify!($SelfT), "::MIN.checked_div_euclid(-1), None);
783783
assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);
784784
```"),
785785
#[stable(feature = "euclidean_division", since = "1.38.0")]
@@ -959,7 +959,7 @@ Basic usage:
959959
960960
```
961961
", $Feature, "assert_eq!(8", stringify!($SelfT), ".checked_pow(2), Some(64));
962-
assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);",
962+
assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);",
963963
$EndFeature, "
964964
```"),
965965

@@ -1000,10 +1000,10 @@ Basic usage:
10001000
10011001
```
10021002
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);
1003-
assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT),
1004-
"::max_value());
1005-
assert_eq!(", stringify!($SelfT), "::min_value().saturating_add(-1), ", stringify!($SelfT),
1006-
"::min_value());",
1003+
assert_eq!(", stringify!($SelfT), "::MAX.saturating_add(100), ", stringify!($SelfT),
1004+
"::MAX);
1005+
assert_eq!(", stringify!($SelfT), "::MIN.saturating_add(-1), ", stringify!($SelfT),
1006+
"::MIN);",
10071007
$EndFeature, "
10081008
```"),
10091009

@@ -1027,10 +1027,10 @@ Basic usage:
10271027
10281028
```
10291029
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27);
1030-
assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT),
1031-
"::min_value());
1032-
assert_eq!(", stringify!($SelfT), "::max_value().saturating_sub(-1), ", stringify!($SelfT),
1033-
"::max_value());",
1030+
assert_eq!(", stringify!($SelfT), "::MIN.saturating_sub(100), ", stringify!($SelfT),
1031+
"::MIN);
1032+
assert_eq!(", stringify!($SelfT), "::MAX.saturating_sub(-1), ", stringify!($SelfT),
1033+
"::MAX);",
10341034
$EndFeature, "
10351035
```"),
10361036
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1055,10 +1055,10 @@ Basic usage:
10551055
", $Feature, "#![feature(saturating_neg)]
10561056
assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
10571057
assert_eq!((-100", stringify!($SelfT), ").saturating_neg(), 100);
1058-
assert_eq!(", stringify!($SelfT), "::min_value().saturating_neg(), ", stringify!($SelfT),
1059-
"::max_value());
1060-
assert_eq!(", stringify!($SelfT), "::max_value().saturating_neg(), ", stringify!($SelfT),
1061-
"::min_value() + 1);",
1058+
assert_eq!(", stringify!($SelfT), "::MIN.saturating_neg(), ", stringify!($SelfT),
1059+
"::MAX);
1060+
assert_eq!(", stringify!($SelfT), "::MAX.saturating_neg(), ", stringify!($SelfT),
1061+
"::MIN + 1);",
10621062
$EndFeature, "
10631063
```"),
10641064

@@ -1082,10 +1082,10 @@ Basic usage:
10821082
", $Feature, "#![feature(saturating_neg)]
10831083
assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
10841084
assert_eq!((-100", stringify!($SelfT), ").saturating_abs(), 100);
1085-
assert_eq!(", stringify!($SelfT), "::min_value().saturating_abs(), ", stringify!($SelfT),
1086-
"::max_value());
1087-
assert_eq!((", stringify!($SelfT), "::min_value() + 1).saturating_abs(), ", stringify!($SelfT),
1088-
"::max_value());",
1085+
assert_eq!(", stringify!($SelfT), "::MIN.saturating_abs(), ", stringify!($SelfT),
1086+
"::MAX);
1087+
assert_eq!((", stringify!($SelfT), "::MIN + 1).saturating_abs(), ", stringify!($SelfT),
1088+
"::MAX);",
10891089
$EndFeature, "
10901090
```"),
10911091

@@ -1171,8 +1171,8 @@ Basic usage:
11711171
11721172
```
11731173
", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_add(27), 127);
1174-
assert_eq!(", stringify!($SelfT), "::max_value().wrapping_add(2), ", stringify!($SelfT),
1175-
"::min_value() + 1);",
1174+
assert_eq!(", stringify!($SelfT), "::MAX.wrapping_add(2), ", stringify!($SelfT),
1175+
"::MIN + 1);",
11761176
$EndFeature, "
11771177
```"),
11781178
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1195,8 +1195,8 @@ Basic usage:
11951195
11961196
```
11971197
", $Feature, "assert_eq!(0", stringify!($SelfT), ".wrapping_sub(127), -127);
1198-
assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::max_value()), ",
1199-
stringify!($SelfT), "::max_value());",
1198+
assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::MAX), ",
1199+
stringify!($SelfT), "::MAX);",
12001200
$EndFeature, "
12011201
```"),
12021202
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1367,8 +1367,8 @@ Basic usage:
13671367
13681368
```
13691369
", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100);
1370-
assert_eq!(", stringify!($SelfT), "::min_value().wrapping_neg(), ", stringify!($SelfT),
1371-
"::min_value());",
1370+
assert_eq!(", stringify!($SelfT), "::MIN.wrapping_neg(), ", stringify!($SelfT),
1371+
"::MIN);",
13721372
$EndFeature, "
13731373
```"),
13741374
#[stable(feature = "num_wrapping", since = "1.2.0")]
@@ -1458,8 +1458,8 @@ Basic usage:
14581458
```
14591459
", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_abs(), 100);
14601460
assert_eq!((-100", stringify!($SelfT), ").wrapping_abs(), 100);
1461-
assert_eq!(", stringify!($SelfT), "::min_value().wrapping_abs(), ", stringify!($SelfT),
1462-
"::min_value());
1461+
assert_eq!(", stringify!($SelfT), "::MIN.wrapping_abs(), ", stringify!($SelfT),
1462+
"::MIN);
14631463
assert_eq!((-128i8).wrapping_abs() as u8, 128);",
14641464
$EndFeature, "
14651465
```"),
@@ -1831,8 +1831,8 @@ Basic usage:
18311831
```
18321832
", $Feature, "assert_eq!(10", stringify!($SelfT), ".overflowing_abs(), (10, false));
18331833
assert_eq!((-10", stringify!($SelfT), ").overflowing_abs(), (10, false));
1834-
assert_eq!((", stringify!($SelfT), "::min_value()).overflowing_abs(), (", stringify!($SelfT),
1835-
"::min_value(), true));",
1834+
assert_eq!((", stringify!($SelfT), "::MIN).overflowing_abs(), (", stringify!($SelfT),
1835+
"::MIN, true));",
18361836
$EndFeature, "
18371837
```"),
18381838
#[stable(feature = "no_panic_abs", since = "1.13.0")]
@@ -2028,10 +2028,10 @@ assert_eq!((-a).rem_euclid(-b), 1);
20282028
20292029
# Overflow behavior
20302030
2031-
The absolute value of `", stringify!($SelfT), "::min_value()` cannot be represented as an
2031+
The absolute value of `", stringify!($SelfT), "::MIN` cannot be represented as an
20322032
`", stringify!($SelfT), "`, and attempting to calculate it will cause an overflow. This means that
20332033
code in debug mode will trigger a panic on this case and optimized code will return `",
2034-
stringify!($SelfT), "::min_value()` without a panic.
2034+
stringify!($SelfT), "::MIN` without a panic.
20352035
20362036
# Examples
20372037
@@ -2505,7 +2505,7 @@ assert_eq!(n.count_ones(), 3);", $EndFeature, "
25052505
Basic usage:
25062506
25072507
```
2508-
", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 0);", $EndFeature, "
2508+
", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 0);", $EndFeature, "
25092509
```"),
25102510
#[stable(feature = "rust1", since = "1.0.0")]
25112511
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
@@ -2523,7 +2523,7 @@ Basic usage:
25232523
Basic usage:
25242524
25252525
```
2526-
", $Feature, "let n = ", stringify!($SelfT), "::max_value() >> 2;
2526+
", $Feature, "let n = ", stringify!($SelfT), "::MAX >> 2;
25272527
25282528
assert_eq!(n.leading_zeros(), 2);", $EndFeature, "
25292529
```"),
@@ -2565,7 +2565,7 @@ Basic usage:
25652565
25662566
```
25672567
", $Feature, "#![feature(leading_trailing_ones)]
2568-
let n = !(", stringify!($SelfT), "::max_value() >> 2);
2568+
let n = !(", stringify!($SelfT), "::MAX >> 2);
25692569
25702570
assert_eq!(n.leading_ones(), 2);", $EndFeature, "
25712571
```"),
@@ -2839,9 +2839,9 @@ if overflow occurred.
28392839
Basic usage:
28402840
28412841
```
2842-
", $Feature, "assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(1), ",
2843-
"Some(", stringify!($SelfT), "::max_value() - 1));
2844-
assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", $EndFeature, "
2842+
", $Feature, "assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(1), ",
2843+
"Some(", stringify!($SelfT), "::MAX - 1));
2844+
assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);", $EndFeature, "
28452845
```"),
28462846
#[stable(feature = "rust1", since = "1.0.0")]
28472847
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
@@ -2887,7 +2887,7 @@ Basic usage:
28872887
28882888
```
28892889
", $Feature, "assert_eq!(5", stringify!($SelfT), ".checked_mul(1), Some(5));
2890-
assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);", $EndFeature, "
2890+
assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);", $EndFeature, "
28912891
```"),
28922892
#[stable(feature = "rust1", since = "1.0.0")]
28932893
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
@@ -3087,7 +3087,7 @@ Basic usage:
30873087
30883088
```
30893089
", $Feature, "assert_eq!(2", stringify!($SelfT), ".checked_pow(5), Some(32));
3090-
assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);", $EndFeature, "
3090+
assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);", $EndFeature, "
30913091
```"),
30923092
#[stable(feature = "no_panic_pow", since = "1.34.0")]
30933093
#[must_use = "this returns the result of the operation, \
@@ -3224,7 +3224,7 @@ Basic usage:
32243224
32253225
```
32263226
", $Feature, "assert_eq!(200", stringify!($SelfT), ".wrapping_add(55), 255);
3227-
assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::max_value()), 199);",
3227+
assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::MAX), 199);",
32283228
$EndFeature, "
32293229
```"),
32303230
#[stable(feature = "rust1", since = "1.0.0")]
@@ -3247,7 +3247,7 @@ Basic usage:
32473247
32483248
```
32493249
", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_sub(100), 0);
3250-
assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::max_value()), 101);",
3250+
assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::MAX), 101);",
32513251
$EndFeature, "
32523252
```"),
32533253
#[stable(feature = "rust1", since = "1.0.0")]
@@ -4029,7 +4029,7 @@ Basic usage:
40294029
", $Feature, "assert_eq!(2", stringify!($SelfT),
40304030
".checked_next_power_of_two(), Some(2));
40314031
assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));
4032-
assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
4032+
assert_eq!(", stringify!($SelfT), "::MAX.checked_next_power_of_two(), None);",
40334033
$EndFeature, "
40344034
```"),
40354035
#[inline]
@@ -4053,7 +4053,7 @@ Basic usage:
40534053
", $Feature, "
40544054
assert_eq!(2", stringify!($SelfT), ".wrapping_next_power_of_two(), 2);
40554055
assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4);
4056-
assert_eq!(", stringify!($SelfT), "::max_value().wrapping_next_power_of_two(), 0);",
4056+
assert_eq!(", stringify!($SelfT), "::MAX.wrapping_next_power_of_two(), 0);",
40574057
$EndFeature, "
40584058
```"),
40594059
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",

0 commit comments

Comments
 (0)