pub fn infer(self, other: Self) -> Result<(Self, Self), ConstMathErr> {
        let inferred = match (self, other) {
            (InferSigned(_), InferSigned(_))
            | (Infer(_), Infer(_)) => self, // no inference possible
            // kindof wrong, you could have had values > I64MAX during computation of a
            (Infer(a @ 0...as_u64::I64MAX), InferSigned(_)) => InferSigned(a as i64),
            (Infer(_), InferSigned(_)) => return Err(ConstMathErr::NotInRange),
            (_, InferSigned(_))
            | (_, Infer(_)) => return other.infer(self).map(|(b, a)| (a, b)),

            (Infer(a @ 0...as_u64::I8MAX), I8(_)) => I8(a as i64 as i8),
            (Infer(a @ 0...as_u64::I16MAX), I16(_)) => I16(a as i64 as i16),
            (Infer(a @ 0...as_u64::I32MAX), I32(_)) => I32(a as i64 as i32),
            (Infer(a @ 0...as_u64::I64MAX), I64(_)) => I64(a as i64),
            (Infer(a @ 0...as_u64::I16MAX), Isize(Is16(_))) => Isize(Is16(a as i64 as i16)),
            (Infer(a @ 0...as_u64::I32MAX), Isize(Is32(_))) => Isize(Is32(a as i64 as i32)),
            (Infer(a @ 0...as_u64::I64MAX), Isize(Is64(_))) => Isize(Is64(a as i64)),
            (Infer(a @ 0...as_u64::U8MAX), U8(_)) => U8(a as u8),
            (Infer(a @ 0...as_u64::U16MAX), U16(_)) => U16(a as u16),
            (Infer(a @ 0...as_u64::U32MAX), U32(_)) => U32(a as u32),
            (Infer(a), U64(_)) => U64(a),
            (Infer(a @ 0...as_u64::U16MAX), Usize(Us16(_))) => Usize(Us16(a as u16)),
            (Infer(a @ 0...as_u64::U32MAX), Usize(Us32(_))) => Usize(Us32(a as u32)),
            (Infer(a), Usize(Us64(_))) => Usize(Us64(a)),

            (Infer(_), _) => return Err(ConstMathErr::NotInRange),

            (InferSigned(a @ as_i64::I8MIN...as_i64::I8MAX), I8(_)) => I8(a as i8),
            (InferSigned(a @ as_i64::I16MIN...as_i64::I16MAX), I16(_)) => I16(a as i16),
            (InferSigned(a @ as_i64::I32MIN...as_i64::I32MAX), I32(_)) => I32(a as i32),
            (InferSigned(a), I64(_)) => I64(a),
            (InferSigned(a @ as_i64::I16MIN...as_i64::I16MAX), Isize(Is16(_))) => {
                Isize(Is16(a as i16))
            },
            (InferSigned(a @ as_i64::I32MIN...as_i64::I32MAX), Isize(Is32(_))) => {
                Isize(Is32(a as i32))
            },
            (InferSigned(a), Isize(Is64(_))) => Isize(Is64(a)),
            (InferSigned(a @ 0...as_i64::U8MAX), U8(_)) => U8(a as u8),
            (InferSigned(a @ 0...as_i64::U16MAX), U16(_)) => U16(a as u16),
            (InferSigned(a @ 0...as_i64::U32MAX), U32(_)) => U32(a as u32),
            (InferSigned(a @ 0...as_i64::I64MAX), U64(_)) => U64(a as u64),
            (InferSigned(a @ 0...as_i64::U16MAX), Usize(Us16(_))) => Usize(Us16(a as u16)),
            (InferSigned(a @ 0...as_i64::U32MAX), Usize(Us32(_))) => Usize(Us32(a as u32)),
            (InferSigned(a @ 0...as_i64::I64MAX), Usize(Us64(_))) => Usize(Us64(a as u64)),
            (InferSigned(_), _) => return Err(ConstMathErr::NotInRange),
            _ => self, // already known types
        };
        Ok((inferred, other))
    }
/// If either value is `Infer` or `InferSigned`, try to turn the value into the type of
/// the other value. If both values have no type, don't do anything
If either value is `Infer` or `InferSigned`, try to turn the value into the type of
the other value. If both values have no type, don't do anything
If either value is ` Infer ` or ` InferSigned ` try to turn the value into the type of the other value . If both values have no type don ' t do anything
pub fn infer(self, other: Self) -> Result<(Self, Self), ConstMathErr> {
        let inferred = match (self, other) {
            (InferSigned(_), InferSigned(_))
            | (Infer(_), Infer(_)) => self, // no inference possible
            // kindof wrong, you could have had values > I64MAX during computation of a
            (Infer(a @ 0...as_u64::I64MAX), InferSigned(_)) => InferSigned(a as i64),
            (Infer(_), InferSigned(_)) => return Err(ConstMathErr::NotInRange),
            (_, InferSigned(_))
            | (_, Infer(_)) => return other.infer(self).map(|(b, a)| (a, b)),
            (Infer(a @ 0...as_u64::I8MAX), I8(_)) => I8(a as i64 as i8),
            (Infer(a @ 0...as_u64::I16MAX), I16(_)) => I16(a as i64 as i16),
            (Infer(a @ 0...as_u64::I32MAX), I32(_)) => I32(a as i64 as i32),
            (Infer(a @ 0...as_u64::I64MAX), I64(_)) => I64(a as i64),
            (Infer(a @ 0...as_u64::I16MAX), Isize(Is16(_))) => Isize(Is16(a as i64 as i16)),
            (Infer(a @ 0...as_u64::I32MAX), Isize(Is32(_))) => Isize(Is32(a as i64 as i32)),
            (Infer(a @ 0...as_u64::I64MAX), Isize(Is64(_))) => Isize(Is64(a as i64)),
            (Infer(a @ 0...as_u64::U8MAX), U8(_)) => U8(a as u8),
            (Infer(a @ 0...as_u64::U16MAX), U16(_)) => U16(a as u16),
            (Infer(a @ 0...as_u64::U32MAX), U32(_)) => U32(a as u32),
            (Infer(a), U64(_)) => U64(a),
            (Infer(a @ 0...as_u64::U16MAX), Usize(Us16(_))) => Usize(Us16(a as u16)),
            (Infer(a @ 0...as_u64::U32MAX), Usize(Us32(_))) => Usize(Us32(a as u32)),
            (Infer(a), Usize(Us64(_))) => Usize(Us64(a)),
            (Infer(_), _) => return Err(ConstMathErr::NotInRange),
            (InferSigned(a @ as_i64::I8MIN...as_i64::I8MAX), I8(_)) => I8(a as i8),
            (InferSigned(a @ as_i64::I16MIN...as_i64::I16MAX), I16(_)) => I16(a as i16),
            (InferSigned(a @ as_i64::I32MIN...as_i64::I32MAX), I32(_)) => I32(a as i32),
            (InferSigned(a), I64(_)) => I64(a),
            (InferSigned(a @ as_i64::I16MIN...as_i64::I16MAX), Isize(Is16(_))) => {
                Isize(Is16(a as i16))
            },
            (InferSigned(a @ as_i64::I32MIN...as_i64::I32MAX), Isize(Is32(_))) => {
                Isize(Is32(a as i32))
            },
            (InferSigned(a), Isize(Is64(_))) => Isize(Is64(a)),
            (InferSigned(a @ 0...as_i64::U8MAX), U8(_)) => U8(a as u8),
            (InferSigned(a @ 0...as_i64::U16MAX), U16(_)) => U16(a as u16),
            (InferSigned(a @ 0...as_i64::U32MAX), U32(_)) => U32(a as u32),
            (InferSigned(a @ 0...as_i64::I64MAX), U64(_)) => U64(a as u64),
            (InferSigned(a @ 0...as_i64::U16MAX), Usize(Us16(_))) => Usize(Us16(a as u16)),
            (InferSigned(a @ 0...as_i64::U32MAX), Usize(Us32(_))) => Usize(Us32(a as u32)),
            (InferSigned(a @ 0...as_i64::I64MAX), Usize(Us64(_))) => Usize(Us64(a as u64)),
            (InferSigned(_), _) => return Err(ConstMathErr::NotInRange),
            _ => self, // already known types
        };
        Ok((inferred, other))
    }
pub fn infer ( self , other : Self ) -> Result < ( Self , Self ) , ConstMathErr > { let inferred = match ( self , other ) { ( InferSigned ( _ ) , InferSigned ( _ ) ) | ( Infer ( _ ) , Infer ( _ ) ) => self , // no inference possible // kindof wrong, you could have had values > I64MAX during computation of a ( Infer ( a @ 0 ... as_u64 :: I64MAX ) , InferSigned ( _ ) ) => InferSigned ( a as i64 ) , ( Infer ( _ ) , InferSigned ( _ ) ) => return Err ( ConstMathErr :: NotInRange ) , ( _ , InferSigned ( _ ) ) | ( _ , Infer ( _ ) ) => return other . infer ( self ) . map ( | ( b , a ) | ( a , b ) ) , ( Infer ( a @ 0 ... as_u64 :: I8MAX ) , I8 ( _ ) ) => I8 ( a as i64 as i8 ) , ( Infer ( a @ 0 ... as_u64 :: I16MAX ) , I16 ( _ ) ) => I16 ( a as i64 as i16 ) , ( Infer ( a @ 0 ... as_u64 :: I32MAX ) , I32 ( _ ) ) => I32 ( a as i64 as i32 ) , ( Infer ( a @ 0 ... as_u64 :: I64MAX ) , I64 ( _ ) ) => I64 ( a as i64 ) , ( Infer ( a @ 0 ... as_u64 :: I16MAX ) , Isize ( Is16 ( _ ) ) ) => Isize ( Is16 ( a as i64 as i16 ) ) , ( Infer ( a @ 0 ... as_u64 :: I32MAX ) , Isize ( Is32 ( _ ) ) ) => Isize ( Is32 ( a as i64 as i32 ) ) , ( Infer ( a @ 0 ... as_u64 :: I64MAX ) , Isize ( Is64 ( _ ) ) ) => Isize ( Is64 ( a as i64 ) ) , ( Infer ( a @ 0 ... as_u64 :: U8MAX ) , U8 ( _ ) ) => U8 ( a as u8 ) , ( Infer ( a @ 0 ... as_u64 :: U16MAX ) , U16 ( _ ) ) => U16 ( a as u16 ) , ( Infer ( a @ 0 ... as_u64 :: U32MAX ) , U32 ( _ ) ) => U32 ( a as u32 ) , ( Infer ( a ) , U64 ( _ ) ) => U64 ( a ) , ( Infer ( a @ 0 ... as_u64 :: U16MAX ) , Usize ( Us16 ( _ ) ) ) => Usize ( Us16 ( a as u16 ) ) , ( Infer ( a @ 0 ... as_u64 :: U32MAX ) , Usize ( Us32 ( _ ) ) ) => Usize ( Us32 ( a as u32 ) ) , ( Infer ( a ) , Usize ( Us64 ( _ ) ) ) => Usize ( Us64 ( a ) ) , ( Infer ( _ ) , _ ) => return Err ( ConstMathErr :: NotInRange ) , ( InferSigned ( a @ as_i64 :: I8MIN ... as_i64 :: I8MAX ) , I8 ( _ ) ) => I8 ( a as i8 ) , ( InferSigned ( a @ as_i64 :: I16MIN ... as_i64 :: I16MAX ) , I16 ( _ ) ) => I16 ( a as i16 ) , ( InferSigned ( a @ as_i64 :: I32MIN ... as_i64 :: I32MAX ) , I32 ( _ ) ) => I32 ( a as i32 ) , ( InferSigned ( a ) , I64 ( _ ) ) => I64 ( a ) , ( InferSigned ( a @ as_i64 :: I16MIN ... as_i64 :: I16MAX ) , Isize ( Is16 ( _ ) ) ) => { Isize ( Is16 ( a as i16 ) ) } , ( InferSigned ( a @ as_i64 :: I32MIN ... as_i64 :: I32MAX ) , Isize ( Is32 ( _ ) ) ) => { Isize ( Is32 ( a as i32 ) ) } , ( InferSigned ( a ) , Isize ( Is64 ( _ ) ) ) => Isize ( Is64 ( a ) ) , ( InferSigned ( a @ 0 ... as_i64 :: U8MAX ) , U8 ( _ ) ) => U8 ( a as u8 ) , ( InferSigned ( a @ 0 ... as_i64 :: U16MAX ) , U16 ( _ ) ) => U16 ( a as u16 ) , ( InferSigned ( a @ 0 ... as_i64 :: U32MAX ) , U32 ( _ ) ) => U32 ( a as u32 ) , ( InferSigned ( a @ 0 ... as_i64 :: I64MAX ) , U64 ( _ ) ) => U64 ( a as u64 ) , ( InferSigned ( a @ 0 ... as_i64 :: U16MAX ) , Usize ( Us16 ( _ ) ) ) => Usize ( Us16 ( a as u16 ) ) , ( InferSigned ( a @ 0 ... as_i64 :: U32MAX ) , Usize ( Us32 ( _ ) ) ) => Usize ( Us32 ( a as u32 ) ) , ( InferSigned ( a @ 0 ... as_i64 :: I64MAX ) , Usize ( Us64 ( _ ) ) ) => Usize ( Us64 ( a as u64 ) ) , ( InferSigned ( _ ) , _ ) => return Err ( ConstMathErr :: NotInRange ) , _ => self , // already known types } ; Ok ( ( inferred , other ) ) }
If either value is `Infer` or `InferSigned`, try to turn the value into the type of
the other value.
If either value is ` Infer ` or ` InferSigned ` try to turn the value into the type of the other value .
self
other
Self
self
other
Self