typenum::type_operators

Trait Cmp

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

Required Associated Types§

Source

type Output

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

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.

Implementors§

Source§

impl Cmp for B0

Source§

impl Cmp for B1

Source§

impl Cmp for Z0

0 == 0

Source§

impl Cmp for UTerm

Zero == Zero

Source§

impl Cmp<B0> for B1

Source§

impl Cmp<B1> for B0

Source§

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

-X <==> -Y

Source§

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

Source§

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

X > - Y

Source§

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

-X < Y

Source§

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

X <==> Y

Source§

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

Source§

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

0 > -X

Source§

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

0 < X

Source§

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

-X < 0

Source§

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

X > 0

Source§

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

Zero < Nonzero

Source§

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

Nonzero > Zero

Source§

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

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

Source§

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

Source§

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

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

Source§

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

Source§

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

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

Source§

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

Source§

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

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

Source§

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