Trait gcd::Gcd

source ·
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§

source

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));
source

fn gcd_binary(self, other: Self) -> Self

source

fn gcd_euclid(self, other: Self) -> Self

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Gcd for u8

source§

fn gcd(self, other: u8) -> u8

source§

fn gcd_binary(self, v: u8) -> u8

source§

fn gcd_euclid(self, other: u8) -> u8

source§

impl Gcd for u16

source§

fn gcd(self, other: u16) -> u16

source§

fn gcd_binary(self, v: u16) -> u16

source§

fn gcd_euclid(self, other: u16) -> u16

source§

impl Gcd for u32

source§

fn gcd(self, other: u32) -> u32

source§

fn gcd_binary(self, v: u32) -> u32

source§

fn gcd_euclid(self, other: u32) -> u32

source§

impl Gcd for u64

source§

fn gcd(self, other: u64) -> u64

source§

fn gcd_binary(self, v: u64) -> u64

source§

fn gcd_euclid(self, other: u64) -> u64

source§

impl Gcd for u128

source§

fn gcd(self, other: u128) -> u128

source§

fn gcd_binary(self, v: u128) -> u128

source§

fn gcd_euclid(self, other: u128) -> u128

source§

impl Gcd for usize

source§

fn gcd(self, other: usize) -> usize

source§

fn gcd_binary(self, v: usize) -> usize

source§

fn gcd_euclid(self, other: usize) -> usize

source§

impl Gcd for NonZeroU8

source§

impl Gcd for NonZeroU16

source§

impl Gcd for NonZeroU32

source§

impl Gcd for NonZeroU64

source§

impl Gcd for NonZeroU128

source§

impl Gcd for NonZeroUsize

Implementors§