Trait libipld::cid::multihash::typenum::Cmp[]

pub trait Cmp<Rhs = Self> {
    type Output;
}
Expand description

A type operator for comparing Self and Rhs. It provides a similar functionality to the function core::cmp::Ord::cmp but for types.

Example

use typenum::{Cmp, Ord, N3, P2, P5};
use std::cmp::Ordering;

assert_eq!(<P2 as Cmp<N3>>::Output::to_ordering(), Ordering::Greater);
assert_eq!(<P2 as Cmp<P2>>::Output::to_ordering(), Ordering::Equal);
assert_eq!(<P2 as Cmp<P5>>::Output::to_ordering(), Ordering::Less);

Associated Types

type Output

The result of the comparison. It should only ever be one of Greater, Less, or Equal.

Implementors

impl Cmp<B0> for B0

type Output = Equal

pub fn compare<P>(&self, &B0) -> <B0 as Cmp<B0>>::Output where
    P: InternalMarker, 

impl Cmp<B0> for B1

type Output = Greater

pub fn compare<P>(&self, &B0) -> <B1 as Cmp<B0>>::Output where
    P: InternalMarker, 

impl Cmp<B1> for B0

type Output = Less

pub fn compare<P>(&self, &B1) -> <B0 as Cmp<B1>>::Output where
    P: InternalMarker, 

impl Cmp<B1> for B1

type Output = Equal

pub fn compare<P>(&self, &B1) -> <B1 as Cmp<B1>>::Output where
    P: InternalMarker, 

impl Cmp<UTerm> for UTerm

Zero == Zero

type Output = Equal

pub fn compare<IM>(&self, &UTerm) -> <UTerm as Cmp<UTerm>>::Output where
    IM: InternalMarker, 

impl Cmp<Z0> for Z0

0 == 0

type Output = Equal

pub fn compare<IM>(&self, &Z0) -> <Z0 as Cmp<Z0>>::Output where
    IM: InternalMarker, 

impl<Nl, Nr> Cmp<NInt<Nr>> for NInt<Nl> where
    Nl: Unsigned + NonZero,
    Nr: Cmp<Nl> + Unsigned + NonZero

-X <==> -Y

type Output = <Nr as Cmp<Nl>>::Output

pub fn compare<IM>(&self, rhs: &NInt<Nr>) -> <NInt<Nl> as Cmp<NInt<Nr>>>::Output where
    IM: InternalMarker, 

impl<P, N> Cmp<NInt<N>> for PInt<P> where
    P: Unsigned + NonZero,
    N: Unsigned + NonZero

X > - Y

type Output = Greater

pub fn compare<IM>(&self, &NInt<N>) -> <PInt<P> as Cmp<NInt<N>>>::Output where
    IM: InternalMarker, 

impl<P, N> Cmp<PInt<P>> for NInt<N> where
    P: Unsigned + NonZero,
    N: Unsigned + NonZero

-X < Y

type Output = Less

pub fn compare<IM>(&self, &PInt<P>) -> <NInt<N> as Cmp<PInt<P>>>::Output where
    IM: InternalMarker, 

impl<Pl, Pr> Cmp<PInt<Pr>> for PInt<Pl> where
    Pl: Cmp<Pr> + Unsigned + NonZero,
    Pr: Unsigned + NonZero

X <==> Y

type Output = <Pl as Cmp<Pr>>::Output

pub fn compare<IM>(&self, rhs: &PInt<Pr>) -> <PInt<Pl> as Cmp<PInt<Pr>>>::Output where
    IM: InternalMarker, 

impl<U> Cmp<NInt<U>> for Z0 where
    U: Unsigned + NonZero

0 > -X

type Output = Greater

pub fn compare<IM>(&self, &NInt<U>) -> <Z0 as Cmp<NInt<U>>>::Output where
    IM: InternalMarker, 

impl<U> Cmp<PInt<U>> for Z0 where
    U: Unsigned + NonZero

0 < X

type Output = Less

pub fn compare<IM>(&self, &PInt<U>) -> <Z0 as Cmp<PInt<U>>>::Output where
    IM: InternalMarker, 

impl<U> Cmp<Z0> for NInt<U> where
    U: Unsigned + NonZero

-X < 0

type Output = Less

pub fn compare<IM>(&self, &Z0) -> <NInt<U> as Cmp<Z0>>::Output where
    IM: InternalMarker, 

impl<U> Cmp<Z0> for PInt<U> where
    U: Unsigned + NonZero

X > 0

type Output = Greater

pub fn compare<IM>(&self, &Z0) -> <PInt<U> as Cmp<Z0>>::Output where
    IM: InternalMarker, 

impl<U, B> Cmp<UInt<U, B>> for UTerm where
    U: Unsigned,
    B: Bit

Zero < Nonzero

type Output = Less

pub fn compare<IM>(&self, &UInt<U, B>) -> <UTerm as Cmp<UInt<U, B>>>::Output where
    IM: InternalMarker, 

impl<U, B> Cmp<UTerm> for UInt<U, B> where
    U: Unsigned,
    B: Bit

Nonzero > Zero

type Output = Greater

pub fn compare<IM>(&self, &UTerm) -> <UInt<U, B> as Cmp<UTerm>>::Output where
    IM: InternalMarker, 

impl<Ul, Ur> Cmp<UInt<Ur, B0>> for UInt<Ul, B0> where
    Ul: Unsigned + PrivateCmp<Ur, Equal>,
    Ur: Unsigned

UInt<Ul, B0> cmp with UInt<Ur, B0>: SoFar is Equal

type Output = <Ul as PrivateCmp<Ur, Equal>>::Output

pub fn compare<IM>(
    &self,
    rhs: &UInt<Ur, B0>
) -> <UInt<Ul, B0> as Cmp<UInt<Ur, B0>>>::Output where
    IM: InternalMarker, 

impl<Ul, Ur> Cmp<UInt<Ur, B0>> for UInt<Ul, B1> where
    Ul: Unsigned + PrivateCmp<Ur, Greater>,
    Ur: Unsigned

UInt<Ul, B1> cmp with UInt<Ur, B0>: SoFar is Greater

type Output = <Ul as PrivateCmp<Ur, Greater>>::Output

pub fn compare<IM>(
    &self,
    rhs: &UInt<Ur, B0>
) -> <UInt<Ul, B1> as Cmp<UInt<Ur, B0>>>::Output where
    IM: InternalMarker, 

impl<Ul, Ur> Cmp<UInt<Ur, B1>> for UInt<Ul, B0> where
    Ul: Unsigned + PrivateCmp<Ur, Less>,
    Ur: Unsigned

UInt<Ul, B0> cmp with UInt<Ur, B1>: SoFar is Less

type Output = <Ul as PrivateCmp<Ur, Less>>::Output

pub fn compare<IM>(
    &self,
    rhs: &UInt<Ur, B1>
) -> <UInt<Ul, B0> as Cmp<UInt<Ur, B1>>>::Output where
    IM: InternalMarker, 

impl<Ul, Ur> Cmp<UInt<Ur, B1>> for UInt<Ul, B1> where
    Ul: Unsigned + PrivateCmp<Ur, Equal>,
    Ur: Unsigned

UInt<Ul, B1> cmp with UInt<Ur, B1>: SoFar is Equal

type Output = <Ul as PrivateCmp<Ur, Equal>>::Output

pub fn compare<IM>(
    &self,
    rhs: &UInt<Ur, B1>
) -> <UInt<Ul, B1> as Cmp<UInt<Ur, B1>>>::Output where
    IM: InternalMarker,