Two wrappers which help controlling behavior of overflow are Wrapping and Saturating.
This is general request, personally I need only small part of it. Currently, I have to reimplement LCM manually:
implCount{pub(crate)fnlcm_saturating(self,other:Self) -> Self{ifself == Self::ZERO || other == Self::ZERO{returnSelf::ZERO;}let gcd = num_integer::gcd(self.0, other.0);match(self.0 / gcd).checked_mul(other.0){Some(lcm) => Self(lcm),None => Self::MAX,}}}When instead it could've been a thin wrapper around num_integer call:
implCount{pub(crate)fnlcm_saturating(self,other:Self) -> Self{Count(num_integer::lcm(Saturating(self.0),Saturating(other.0)).0)}}
Two wrappers which help controlling behavior of overflow are
WrappingandSaturating.This is general request, personally I need only small part of it. Currently, I have to reimplement LCM manually:
When instead it could've been a thin wrapper around
num_integercall: