File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,32 @@ macro_rules! nonzero_signed_operations {
713
713
unsafe { $Uty:: new_unchecked( self . get( ) . unsigned_abs( ) ) }
714
714
}
715
715
716
+ /// Returns `true` if `self` is positive and `false` if the
717
+ /// number is negative.
718
+ ///
719
+ /// # Example
720
+ ///
721
+ /// ```
722
+ /// #![feature(nonzero_negation_ops)]
723
+ ///
724
+ #[ doc = concat!( "# use std::num::" , stringify!( $Ty) , ";" ) ]
725
+ /// # fn main() { test().unwrap(); }
726
+ /// # fn test() -> Option<()> {
727
+ #[ doc = concat!( "let pos_five = " , stringify!( $Ty) , "::new(5)?;" ) ]
728
+ #[ doc = concat!( "let neg_five = " , stringify!( $Ty) , "::new(-5)?;" ) ]
729
+ ///
730
+ /// assert!(pos_five.is_positive());
731
+ /// assert!(!neg_five.is_positive());
732
+ /// # Some(())
733
+ /// # }
734
+ /// ```
735
+ #[ must_use]
736
+ #[ inline]
737
+ #[ unstable( feature = "nonzero_negation_ops" , issue = "102443" ) ]
738
+ pub const fn is_positive( self ) -> bool {
739
+ self . get( ) . is_positive( )
740
+ }
741
+
716
742
/// Returns `true` if `self` is negative and `false` if the
717
743
/// number is positive.
718
744
///
You can’t perform that action at this time.
0 commit comments