Skip to content

Stabilize euclidean modulo methods #52547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
16 changes: 8 additions & 8 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ assert_eq!(5", stringify!($SelfT), ".checked_mod_euc(2), Some(1));
assert_eq!(5", stringify!($SelfT), ".checked_mod_euc(0), None);
assert_eq!(", stringify!($SelfT), "::MIN.checked_mod_euc(-1), None);
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
pub fn checked_mod_euc(self, rhs: Self) -> Option<Self> {
if rhs == 0 || (self == Self::min_value() && rhs == -1) {
Expand Down Expand Up @@ -1244,7 +1244,7 @@ Basic usage:
assert_eq!(100", stringify!($SelfT), ".wrapping_mod_euc(10), 0);
assert_eq!((-128i8).wrapping_mod_euc(-1), 0);
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
pub fn wrapping_mod_euc(self, rhs: Self) -> Self {
self.overflowing_mod_euc(rhs).0
Expand Down Expand Up @@ -1603,7 +1603,7 @@ use std::", stringify!($SelfT), ";
assert_eq!(5", stringify!($SelfT), ".overflowing_mod_euc(2), (1, false));
assert_eq!(", stringify!($SelfT), "::MIN.overflowing_mod_euc(-1), (0, true));
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
pub fn overflowing_mod_euc(self, rhs: Self) -> (Self, bool) {
if self == Self::min_value() && rhs == -1 {
Expand Down Expand Up @@ -1870,7 +1870,7 @@ assert_eq!((-a).mod_euc(b), 1);
assert_eq!(a.mod_euc(-b), 3);
assert_eq!((-a).mod_euc(-b), 1);
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
#[rustc_inherit_overflow_checks]
pub fn mod_euc(self, rhs: Self) -> Self {
Expand Down Expand Up @@ -2712,7 +2712,7 @@ Basic usage:
assert_eq!(5", stringify!($SelfT), ".checked_mod_euc(2), Some(1));
assert_eq!(5", stringify!($SelfT), ".checked_mod_euc(0), None);
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
pub fn checked_mod_euc(self, rhs: Self) -> Option<Self> {
if rhs == 0 {
Expand Down Expand Up @@ -3062,7 +3062,7 @@ Basic usage:
#![feature(euclidean_division)]
assert_eq!(100", stringify!($SelfT), ".wrapping_mod_euc(10), 0);
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
pub fn wrapping_mod_euc(self, rhs: Self) -> Self {
self % rhs
Expand Down Expand Up @@ -3376,7 +3376,7 @@ Basic usage
assert_eq!(5", stringify!($SelfT), ".overflowing_mod_euc(2), (1, false));
```"),
#[inline]
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
pub fn overflowing_mod_euc(self, rhs: Self) -> (Self, bool) {
(self % rhs, false)
}
Expand Down Expand Up @@ -3574,7 +3574,7 @@ Basic usage:
#![feature(euclidean_division)]
assert_eq!(7", stringify!($SelfT), ".mod_euc(4), 3); // or any other integer type
```"),
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
#[inline]
#[rustc_inherit_overflow_checks]
pub fn mod_euc(self, rhs: Self) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl f32 {
/// assert_eq!((-a).mod_euc(-b), 1.0);
/// ```
#[inline]
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
pub fn mod_euc(self, rhs: f32) -> f32 {
let r = self % rhs;
if r < 0.0 {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl f64 {
/// assert_eq!((-a).mod_euc(-b), 1.0);
/// ```
#[inline]
#[unstable(feature = "euclidean_division", issue = "49048")]
#[stable(feature = "euclidean_modulo", since = "1.29.0")]
pub fn mod_euc(self, rhs: f64) -> f64 {
let r = self % rhs;
if r < 0.0 {
Expand Down