pub trait Gcd<Other = Self> {
type Output;
// Required method
fn gcd(self, other: Other) -> Self::Output;
}Required Associated Types§
Required Methods§
Sourcefn gcd(self, other: Other) -> Self::Output
fn gcd(self, other: Other) -> Self::Output
Returns greatest common divisor.
use traiter::numbers::Gcd;
// signed integers
assert_eq!(Gcd::gcd(-3i8, 3i8), 3i8);
assert_eq!(Gcd::gcd(-3i8, 2i8), 1i8);
assert_eq!(Gcd::gcd(-3i8, 0i8), 3i8);
// unsigned integers
assert_eq!(Gcd::gcd(3u8, 3u8), 3u8);
assert_eq!(Gcd::gcd(3u8, 2u8), 1u8);
assert_eq!(Gcd::gcd(3u8, 0u8), 3u8);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".