I\'m trying to implement an algorithm which relies on modular exponentiation. I couldn\'t find any modular exponentiation construct for native types like u64
(only
You can either ignore the problem and compare a reference to a reference or non-reference to a non-reference:
if modulus == &T::one() {
// Or
if *modulus == T::one() {
Or you can use higher-ranked trait bounds:
impl PowM for T
where
T: Num + Two + ShrAssign + Rem + PartialOrd,
for <'a> &'a T: PartialEq,
{
// ...
}
In either case, you need to require that T
implements Copy
or that it implements Clone
and then add appropriate calls to .clone()
.
See also: