This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 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 {
713713 unsafe { $Uty:: new_unchecked( self . get( ) . unsigned_abs( ) ) }
714714 }
715715
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+
716742 /// Returns `true` if `self` is negative and `false` if the
717743 /// number is positive.
718744 ///
You can’t perform that action at this time.
0 commit comments