Skip to content

Commit 72ac8ce

Browse files
committed
Stablize Euclidean Modulo (feature euclidean_division)
1 parent b0bd5f2 commit 72ac8ce

File tree

4 files changed

+20
-41
lines changed

4 files changed

+20
-41
lines changed

src/libcore/num/mod.rs

+16-32
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,12 @@ returning `None` if `rhs == 0` or the division results in overflow.
717717
Basic usage:
718718
719719
```
720-
#![feature(euclidean_division)]
721720
assert_eq!((", stringify!($SelfT),
722721
"::min_value() + 1).checked_div_euclid(-1), Some(", stringify!($Max), "));
723722
assert_eq!(", stringify!($SelfT), "::min_value().checked_div_euclid(-1), None);
724723
assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);
725724
```"),
726-
#[unstable(feature = "euclidean_division", issue = "49048")]
725+
#[stable(feature = "euclidean_division", since = "1.38.0")]
727726
#[must_use = "this returns the result of the operation, \
728727
without modifying the original"]
729728
#[inline]
@@ -774,14 +773,13 @@ if `rhs == 0` or the division results in overflow.
774773
Basic usage:
775774
776775
```
777-
#![feature(euclidean_division)]
778776
use std::", stringify!($SelfT), ";
779777
780778
assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(2), Some(1));
781779
assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None);
782780
assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None);
783781
```"),
784-
#[unstable(feature = "euclidean_division", issue = "49048")]
782+
#[stable(feature = "euclidean_division", since = "1.38.0")]
785783
#[must_use = "this returns the result of the operation, \
786784
without modifying the original"]
787785
#[inline]
@@ -1210,11 +1208,10 @@ This function will panic if `rhs` is 0.
12101208
Basic usage:
12111209
12121210
```
1213-
#![feature(euclidean_division)]
12141211
assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10);
12151212
assert_eq!((-128i8).wrapping_div_euclid(-1), -128);
12161213
```"),
1217-
#[unstable(feature = "euclidean_division", issue = "49048")]
1214+
#[stable(feature = "euclidean_division", since = "1.38.0")]
12181215
#[must_use = "this returns the result of the operation, \
12191216
without modifying the original"]
12201217
#[inline]
@@ -1269,11 +1266,10 @@ This function will panic if `rhs` is 0.
12691266
Basic usage:
12701267
12711268
```
1272-
#![feature(euclidean_division)]
12731269
assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);
12741270
assert_eq!((-128i8).wrapping_rem_euclid(-1), 0);
12751271
```"),
1276-
#[unstable(feature = "euclidean_division", issue = "49048")]
1272+
#[stable(feature = "euclidean_division", since = "1.38.0")]
12771273
#[must_use = "this returns the result of the operation, \
12781274
without modifying the original"]
12791275
#[inline]
@@ -1566,15 +1562,14 @@ This function will panic if `rhs` is 0.
15661562
Basic usage:
15671563
15681564
```
1569-
#![feature(euclidean_division)]
15701565
use std::", stringify!($SelfT), ";
15711566
15721567
assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false));
15731568
assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div_euclid(-1), (", stringify!($SelfT),
15741569
"::MIN, true));
15751570
```"),
15761571
#[inline]
1577-
#[unstable(feature = "euclidean_division", issue = "49048")]
1572+
#[stable(feature = "euclidean_division", since = "1.38.0")]
15781573
#[must_use = "this returns the result of the operation, \
15791574
without modifying the original"]
15801575
pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
@@ -1636,13 +1631,12 @@ This function will panic if `rhs` is 0.
16361631
Basic usage:
16371632
16381633
```
1639-
#![feature(euclidean_division)]
16401634
use std::", stringify!($SelfT), ";
16411635
16421636
assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false));
16431637
assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true));
16441638
```"),
1645-
#[unstable(feature = "euclidean_division", issue = "49048")]
1639+
#[stable(feature = "euclidean_division", since = "1.38.0")]
16461640
#[must_use = "this returns the result of the operation, \
16471641
without modifying the original"]
16481642
#[inline]
@@ -1873,7 +1867,6 @@ This function will panic if `rhs` is 0.
18731867
Basic usage:
18741868
18751869
```
1876-
#![feature(euclidean_division)]
18771870
let a: ", stringify!($SelfT), " = 7; // or any other integer type
18781871
let b = 4;
18791872
@@ -1882,7 +1875,7 @@ assert_eq!(a.div_euclid(-b), -1); // 7 >= -4 * -1
18821875
assert_eq!((-a).div_euclid(b), -2); // -7 >= 4 * -2
18831876
assert_eq!((-a).div_euclid(-b), 2); // -7 >= -4 * 2
18841877
```"),
1885-
#[unstable(feature = "euclidean_division", issue = "49048")]
1878+
#[stable(feature = "euclidean_division", since = "1.38.0")]
18861879
#[must_use = "this returns the result of the operation, \
18871880
without modifying the original"]
18881881
#[inline]
@@ -1913,7 +1906,6 @@ This function will panic if `rhs` is 0.
19131906
Basic usage:
19141907
19151908
```
1916-
#![feature(euclidean_division)]
19171909
let a: ", stringify!($SelfT), " = 7; // or any other integer type
19181910
let b = 4;
19191911
@@ -1922,7 +1914,7 @@ assert_eq!((-a).rem_euclid(b), 1);
19221914
assert_eq!(a.rem_euclid(-b), 3);
19231915
assert_eq!((-a).rem_euclid(-b), 1);
19241916
```"),
1925-
#[unstable(feature = "euclidean_division", issue = "49048")]
1917+
#[stable(feature = "euclidean_division", since = "1.38.0")]
19261918
#[must_use = "this returns the result of the operation, \
19271919
without modifying the original"]
19281920
#[inline]
@@ -2753,11 +2745,10 @@ if `rhs == 0`.
27532745
Basic usage:
27542746
27552747
```
2756-
#![feature(euclidean_division)]
27572748
assert_eq!(128", stringify!($SelfT), ".checked_div_euclid(2), Some(64));
27582749
assert_eq!(1", stringify!($SelfT), ".checked_div_euclid(0), None);
27592750
```"),
2760-
#[unstable(feature = "euclidean_division", issue = "49048")]
2751+
#[stable(feature = "euclidean_division", since = "1.38.0")]
27612752
#[must_use = "this returns the result of the operation, \
27622753
without modifying the original"]
27632754
#[inline]
@@ -2805,11 +2796,10 @@ if `rhs == 0`.
28052796
Basic usage:
28062797
28072798
```
2808-
#![feature(euclidean_division)]
28092799
assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(2), Some(1));
28102800
assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None);
28112801
```"),
2812-
#[unstable(feature = "euclidean_division", issue = "49048")]
2802+
#[stable(feature = "euclidean_division", since = "1.38.0")]
28132803
#[must_use = "this returns the result of the operation, \
28142804
without modifying the original"]
28152805
#[inline]
@@ -3127,10 +3117,9 @@ is exactly equal to `self.wrapping_div(rhs)`.
31273117
Basic usage:
31283118
31293119
```
3130-
#![feature(euclidean_division)]
31313120
assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10);
31323121
```"),
3133-
#[unstable(feature = "euclidean_division", issue = "49048")]
3122+
#[stable(feature = "euclidean_division", since = "1.38.0")]
31343123
#[must_use = "this returns the result of the operation, \
31353124
without modifying the original"]
31363125
#[inline]
@@ -3179,10 +3168,9 @@ is exactly equal to `self.wrapping_rem(rhs)`.
31793168
Basic usage:
31803169
31813170
```
3182-
#![feature(euclidean_division)]
31833171
assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);
31843172
```"),
3185-
#[unstable(feature = "euclidean_division", issue = "49048")]
3173+
#[stable(feature = "euclidean_division", since = "1.38.0")]
31863174
#[must_use = "this returns the result of the operation, \
31873175
without modifying the original"]
31883176
#[inline]
@@ -3448,11 +3436,10 @@ This function will panic if `rhs` is 0.
34483436
Basic usage
34493437
34503438
```
3451-
#![feature(euclidean_division)]
34523439
assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false));
34533440
```"),
34543441
#[inline]
3455-
#[unstable(feature = "euclidean_division", issue = "49048")]
3442+
#[stable(feature = "euclidean_division", since = "1.38.0")]
34563443
#[must_use = "this returns the result of the operation, \
34573444
without modifying the original"]
34583445
pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
@@ -3508,11 +3495,10 @@ This function will panic if `rhs` is 0.
35083495
Basic usage
35093496
35103497
```
3511-
#![feature(euclidean_division)]
35123498
assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false));
35133499
```"),
35143500
#[inline]
3515-
#[unstable(feature = "euclidean_division", issue = "49048")]
3501+
#[stable(feature = "euclidean_division", since = "1.38.0")]
35163502
#[must_use = "this returns the result of the operation, \
35173503
without modifying the original"]
35183504
pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) {
@@ -3696,10 +3682,9 @@ is exactly equal to `self / rhs`.
36963682
Basic usage:
36973683
36983684
```
3699-
#![feature(euclidean_division)]
37003685
assert_eq!(7", stringify!($SelfT), ".div_euclid(4), 1); // or any other integer type
37013686
```"),
3702-
#[unstable(feature = "euclidean_division", issue = "49048")]
3687+
#[stable(feature = "euclidean_division", since = "1.38.0")]
37033688
#[must_use = "this returns the result of the operation, \
37043689
without modifying the original"]
37053690
#[inline]
@@ -3722,10 +3707,9 @@ is exactly equal to `self % rhs`.
37223707
Basic usage:
37233708
37243709
```
3725-
#![feature(euclidean_division)]
37263710
assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer type
37273711
```"),
3728-
#[unstable(feature = "euclidean_division", issue = "49048")]
3712+
#[stable(feature = "euclidean_division", since = "1.38.0")]
37293713
#[must_use = "this returns the result of the operation, \
37303714
without modifying the original"]
37313715
#[inline]

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![feature(core_private_bignum)]
55
#![feature(core_private_diy_float)]
66
#![feature(dec2flt)]
7-
#![feature(euclidean_division)]
87
#![feature(exact_size_is_empty)]
98
#![feature(fixed_size_array)]
109
#![feature(flt2dec)]

src/libstd/f32.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ impl f32 {
256256
/// # Examples
257257
///
258258
/// ```
259-
/// #![feature(euclidean_division)]
260259
/// let a: f32 = 7.0;
261260
/// let b = 4.0;
262261
/// assert_eq!(a.div_euclid(b), 1.0); // 7.0 > 4.0 * 1.0
@@ -265,7 +264,7 @@ impl f32 {
265264
/// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
266265
/// ```
267266
#[inline]
268-
#[unstable(feature = "euclidean_division", issue = "49048")]
267+
#[stable(feature = "euclidean_division", since = "1.38.0")]
269268
pub fn div_euclid(self, rhs: f32) -> f32 {
270269
let q = (self / rhs).trunc();
271270
if self % rhs < 0.0 {
@@ -288,7 +287,6 @@ impl f32 {
288287
/// # Examples
289288
///
290289
/// ```
291-
/// #![feature(euclidean_division)]
292290
/// let a: f32 = 7.0;
293291
/// let b = 4.0;
294292
/// assert_eq!(a.rem_euclid(b), 3.0);
@@ -299,7 +297,7 @@ impl f32 {
299297
/// assert!((-std::f32::EPSILON).rem_euclid(3.0) != 0.0);
300298
/// ```
301299
#[inline]
302-
#[unstable(feature = "euclidean_division", issue = "49048")]
300+
#[stable(feature = "euclidean_division", since = "1.38.0")]
303301
pub fn rem_euclid(self, rhs: f32) -> f32 {
304302
let r = self % rhs;
305303
if r < 0.0 {

src/libstd/f64.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ impl f64 {
232232
/// # Examples
233233
///
234234
/// ```
235-
/// #![feature(euclidean_division)]
236235
/// let a: f64 = 7.0;
237236
/// let b = 4.0;
238237
/// assert_eq!(a.div_euclid(b), 1.0); // 7.0 > 4.0 * 1.0
@@ -241,7 +240,7 @@ impl f64 {
241240
/// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
242241
/// ```
243242
#[inline]
244-
#[unstable(feature = "euclidean_division", issue = "49048")]
243+
#[stable(feature = "euclidean_division", since = "1.38.0")]
245244
pub fn div_euclid(self, rhs: f64) -> f64 {
246245
let q = (self / rhs).trunc();
247246
if self % rhs < 0.0 {
@@ -264,7 +263,6 @@ impl f64 {
264263
/// # Examples
265264
///
266265
/// ```
267-
/// #![feature(euclidean_division)]
268266
/// let a: f64 = 7.0;
269267
/// let b = 4.0;
270268
/// assert_eq!(a.rem_euclid(b), 3.0);
@@ -275,7 +273,7 @@ impl f64 {
275273
/// assert!((-std::f64::EPSILON).rem_euclid(3.0) != 0.0);
276274
/// ```
277275
#[inline]
278-
#[unstable(feature = "euclidean_division", issue = "49048")]
276+
#[stable(feature = "euclidean_division", since = "1.38.0")]
279277
pub fn rem_euclid(self, rhs: f64) -> f64 {
280278
let r = self % rhs;
281279
if r < 0.0 {

0 commit comments

Comments
 (0)