pub trait Gcd {
// Required methods
fn gcd(self, other: Self) -> Self;
fn gcd_binary(self, other: Self) -> Self;
fn gcd_euclid(self, other: Self) -> Self;
}
Required Methods§
Sourcefn gcd(self, other: Self) -> Self
fn gcd(self, other: Self) -> Self
Determine greatest common divisor
using gcd_binary
.
§Examples
use gcd::Gcd;
assert_eq!(0, 0u8.gcd(0));
assert_eq!(10, 10u8.gcd(0));
assert_eq!(10, 0u8.gcd(10));
assert_eq!(10, 10u8.gcd(20));
assert_eq!(44, 2024u32.gcd(748));
Sourcefn gcd_binary(self, other: Self) -> Self
fn gcd_binary(self, other: Self) -> Self
Determine greatest common divisor using the Binary GCD algorithm.
Sourcefn gcd_euclid(self, other: Self) -> Self
fn gcd_euclid(self, other: Self) -> Self
Determine greatest common divisor using the Euclidean algorithm.
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.