pub trait UpcastPow<H>:
Upcast<Higher = H>
+ CheckedPow
+ Copy
+ Rem<Output = Self>{
// Provided methods
fn upcast_pow(self, exp: u32) -> H { ... }
fn upcast_pow_mod(self, exp: u32, modulo: Self) -> Self { ... }
}
Expand description
Trait to perform upcast pow. (Casting up when type bounds are hit during arithmetic)
§Why the additional bounds?
The algorithm to perform (self % rhs) % modulo
is not as straightforward as the other
algorithms. The reason behind this is a more complex algorithm used to calculate (self * rhs) % modulo
.
Provided Methods§
Sourcefn upcast_pow(self, exp: u32) -> H
fn upcast_pow(self, exp: u32) -> H
performs the operation self * rhs
and returns a value of type H.
Sourcefn upcast_pow_mod(self, exp: u32, modulo: Self) -> Self
fn upcast_pow_mod(self, exp: u32, modulo: Self) -> Self
performs the operation (self * rhs) % modulo
and returns a value of type Self.
The implementation uses the Right-to-left binary method.
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.