@@ -60,6 +60,9 @@ pub trait PrimitiveSigned: PrimitiveInteger + From<i8> + core::ops::Neg<Output =
6060 /// Computes the absolute difference between `self` and `other`.
6161 fn abs_diff ( self , other : Self ) -> Self :: Unsigned ;
6262
63+ /// Returns the bit pattern of `self` reinterpreted as an unsigned integer of the same size.
64+ fn cast_unsigned ( self ) -> Self :: Unsigned ;
65+
6366 /// Checked absolute value. Computes `self.abs()`, returning `None` if `self == MIN`.
6467 fn checked_abs ( self ) -> Option < Self > ;
6568
@@ -80,6 +83,9 @@ pub trait PrimitiveSigned: PrimitiveInteger + From<i8> + core::ops::Neg<Output =
8083 /// Returns true if `self` is positive and false if the number is zero or negative.
8184 fn is_positive ( self ) -> bool ;
8285
86+ /// Calculates the middle point of `self` and `other`.
87+ fn midpoint ( self , other : Self ) -> Self ;
88+
8389 /// Computes the absolute value of `self`. Returns a tuple of the absolute version of `self`
8490 /// along with a boolean indicating whether an overflow happened.
8591 fn overflowing_abs ( self ) -> ( Self , bool ) ;
@@ -141,12 +147,14 @@ macro_rules! impl_signed {
141147 forward! {
142148 fn abs( self ) -> Self ;
143149 fn abs_diff( self , other: Self ) -> Self :: Unsigned ;
150+ fn cast_unsigned( self ) -> Self :: Unsigned ;
144151 fn checked_abs( self ) -> Option <Self >;
145152 fn checked_add_unsigned( self , rhs: Self :: Unsigned ) -> Option <Self >;
146153 fn checked_isqrt( self ) -> Option <Self >;
147154 fn checked_sub_unsigned( self , rhs: Self :: Unsigned ) -> Option <Self >;
148155 fn is_negative( self ) -> bool ;
149156 fn is_positive( self ) -> bool ;
157+ fn midpoint( self , other: Self ) -> Self ;
150158 fn overflowing_abs( self ) -> ( Self , bool ) ;
151159 fn overflowing_add_unsigned( self , rhs: Self :: Unsigned ) -> ( Self , bool ) ;
152160 fn overflowing_sub_unsigned( self , rhs: Self :: Unsigned ) -> ( Self , bool ) ;
0 commit comments