pub trait UpcastMul<H: Mul<Output = H> + Rem<Output = H>>:
Upcast<Higher = H>
+ CheckedMul
+ Rem<Output = Self>
+ Copy {
// Provided methods
fn upcast_mul(self, rhs: Self) -> H { ... }
fn upcast_mul_mod(self, rhs: Self, modulo: Self) -> Self { ... }
}
Expand description
Trait to implement upcast mul. (Casting up when type bounds are hit during arithmetic)
Provided Methods§
Sourcefn upcast_mul(self, rhs: Self) -> H
fn upcast_mul(self, rhs: Self) -> H
performs the operation self * rhs
and returns a value of type H.
let a = u8::MAX;
let b = 2;
let expected = u8::MAX as u16 * 2;
let res = a.upcast_mul(b);
assert_eq!(res, expected);
Sourcefn upcast_mul_mod(self, rhs: Self, modulo: Self) -> Self
fn upcast_mul_mod(self, rhs: Self, modulo: Self) -> Self
performs the operation (self * rhs) % modulo
and returns the a value of type Self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.