pub trait Unsigned: IntBase {
type Signed: Signed<Unsigned = Self>;
// Required methods
fn signed(self) -> Self::Signed;
fn abs_diff(self, other: Self) -> Self;
fn next_power_of_two(self) -> Self;
fn gcd(self, other: Self) -> Self;
// Provided methods
fn lcm(self, other: Self) -> Self { ... }
fn extgcd(self, other: Self) -> ExtendedGcd<Self> { ... }
fn modinv(self, modulo: Self) -> Self { ... }
}
Expand description
Trait for unsigned integer operations.
Required Associated Types§
Required Methods§
fn signed(self) -> Self::Signed
fn abs_diff(self, other: Self) -> Self
fn next_power_of_two(self) -> Self
fn gcd(self, other: Self) -> Self
Provided Methods§
fn lcm(self, other: Self) -> Self
Sourcefn extgcd(self, other: Self) -> ExtendedGcd<Self>
fn extgcd(self, other: Self) -> ExtendedGcd<Self>
Examples found in repository?
crates/competitive/src/num/integer.rs (line 119)
113 fn modinv(self, modulo: Self) -> Self {
114 assert!(
115 !self.is_zero(),
116 "attempt to inverse zero with modulo {}",
117 modulo
118 );
119 let extgcd = self.extgcd(modulo);
120 assert!(
121 extgcd.g.is_one(),
122 "there is no inverse {} modulo {}",
123 self,
124 modulo
125 );
126 extgcd.x.rem_euclid(modulo.signed()).unsigned()
127 }
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.