1
Fork 0

Stabilize feature nonzero_negation_ops

This commit is contained in:
John Millikin 2023-05-01 11:04:10 +09:00
parent eb7a743421
commit bfa3e8add4

View file

@ -719,8 +719,6 @@ macro_rules! nonzero_signed_operations {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")] #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); } /// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> { /// # fn test() -> Option<()> {
@ -734,7 +732,8 @@ macro_rules! nonzero_signed_operations {
/// ``` /// ```
#[must_use] #[must_use]
#[inline] #[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")] #[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn is_positive(self) -> bool { pub const fn is_positive(self) -> bool {
self.get().is_positive() self.get().is_positive()
} }
@ -745,8 +744,6 @@ macro_rules! nonzero_signed_operations {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")] #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); } /// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> { /// # fn test() -> Option<()> {
@ -760,7 +757,8 @@ macro_rules! nonzero_signed_operations {
/// ``` /// ```
#[must_use] #[must_use]
#[inline] #[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")] #[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn is_negative(self) -> bool { pub const fn is_negative(self) -> bool {
self.get().is_negative() self.get().is_negative()
} }
@ -770,8 +768,6 @@ macro_rules! nonzero_signed_operations {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")] #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); } /// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> { /// # fn test() -> Option<()> {
@ -786,7 +782,8 @@ macro_rules! nonzero_signed_operations {
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")] #[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn checked_neg(self) -> Option<$Ty> { pub const fn checked_neg(self) -> Option<$Ty> {
if let Some(result) = self.get().checked_neg() { if let Some(result) = self.get().checked_neg() {
// SAFETY: negation of nonzero cannot yield zero values. // SAFETY: negation of nonzero cannot yield zero values.
@ -803,8 +800,6 @@ macro_rules! nonzero_signed_operations {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")] #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); } /// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> { /// # fn test() -> Option<()> {
@ -819,7 +814,8 @@ macro_rules! nonzero_signed_operations {
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")] #[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn overflowing_neg(self) -> ($Ty, bool) { pub const fn overflowing_neg(self) -> ($Ty, bool) {
let (result, overflow) = self.get().overflowing_neg(); let (result, overflow) = self.get().overflowing_neg();
// SAFETY: negation of nonzero cannot yield zero values. // SAFETY: negation of nonzero cannot yield zero values.
@ -832,8 +828,6 @@ macro_rules! nonzero_signed_operations {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")] #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); } /// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> { /// # fn test() -> Option<()> {
@ -853,7 +847,8 @@ macro_rules! nonzero_signed_operations {
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")] #[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn saturating_neg(self) -> $Ty { pub const fn saturating_neg(self) -> $Ty {
if let Some(result) = self.checked_neg() { if let Some(result) = self.checked_neg() {
return result; return result;
@ -870,8 +865,6 @@ macro_rules! nonzero_signed_operations {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")] #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); } /// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> { /// # fn test() -> Option<()> {
@ -886,7 +879,8 @@ macro_rules! nonzero_signed_operations {
/// # } /// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")] #[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn wrapping_neg(self) -> $Ty { pub const fn wrapping_neg(self) -> $Ty {
let result = self.get().wrapping_neg(); let result = self.get().wrapping_neg();
// SAFETY: negation of nonzero cannot yield zero values. // SAFETY: negation of nonzero cannot yield zero values.