Skip to main content

Cmp

Struct Cmp 

Source
#[repr(transparent)]
pub struct Cmp<T>(pub T);
Expand description

🛠️ Provides comparing methods for T.


📍 num/fin/ord


This wrapper exposes comparison operations as value methods, enabling uniform and const-evaluable comparisons across primitives.

It provides the non-const methods pclamp, pmax, pmin for comparing PartialOrdered values.

It provides the following const methods for comparing primitives: clamp, max, min, eq, ne, lt, le, gt, ge.

It also allows compile-time comparison between Orderings.

In the case of floating-point primitives:

  • total ordering is used.
  • additional methods are provided: is_positive, is_negative, is_finite, is_infinite, is_nan.

See also the cmp! macro for an operation-first syntax.

Tuple Fields§

§0: T

Implementations§

Source§

impl<T: PartialOrd> Cmp<T>

Source

pub fn pclamp(self, min: T, max: T) -> Option<T>

Compares and returns a PartialOrdered value clamped between min and max.

Returns None if comparisons are indeterminate.

§Examples
assert_eq![Some(0.4), Cmp(1.0).pclamp(0.2, 0.4)];
assert_eq![Some(0.2), Cmp(0.0).pclamp(0.2, 0.4)];
//
assert_eq![None, Cmp(1.0).pclamp(f32::NAN, f32::NAN)];
assert_eq![None, Cmp(1.0).pclamp(f32::NAN, 0.4)];
assert_eq![None, Cmp(1.0).pclamp(0.2, f32::NAN)];
Source

pub fn pmax(self, other: T) -> Option<T>

Compares and returns the maximum of two PartialOrdered values.

Returns None if comparisons are indeterminate.

Complements core::cmp::max which requires Ord

§Examples
assert_eq![Some(0.4), Cmp(0.2).pmax(0.4)];
//
assert_eq![None, Cmp(0.2).pmax(f32::NAN)];
assert_eq![None, Cmp(f32::NAN).pmax(0.4)];
Source

pub fn pmin(self, other: T) -> Option<T>

Compares and returns the minimum of two PartialOrdered values.

Returns None if comparisons are indeterminate.

Complements core::cmp::min which requires Ord

§Examples
assert_eq![Some(0.2), Cmp(0.2).pmin(0.4)];
//
assert_eq![None, Cmp(0.2).pmin(f32::NAN)];
assert_eq![None, Cmp(f32::NAN).pmin(0.4)];
Source

pub fn pminmax(self, other: T) -> Option<(T, T)>

Compares, orders, and returns both (minimum, maximum) PartialOrdered values.

Returns None if comparisons are indeterminate.

§Examples
assert_eq![Some((0.2, 0.4)), Cmp(0.4).pminmax(0.2)];
//
assert_eq![None, Cmp(0.2).pminmax(f32::NAN)];
assert_eq![None, Cmp(f32::NAN).pminmax(0.4)];
Source§

impl Cmp<u8>

Source

pub const fn total_cmp(self, other: u8) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: u8, max: u8) -> u8

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: u8) -> u8

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: u8) -> u8

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: u8) -> (u8, u8)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: u8) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: u8) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: u8) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: u8) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: u8) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: u8) -> bool

Returns true if self >= other.

Source§

impl Cmp<u16>

Source

pub const fn total_cmp(self, other: u16) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: u16, max: u16) -> u16

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: u16) -> u16

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: u16) -> u16

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: u16) -> (u16, u16)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: u16) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: u16) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: u16) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: u16) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: u16) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: u16) -> bool

Returns true if self >= other.

Source§

impl Cmp<u32>

Source

pub const fn total_cmp(self, other: u32) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: u32, max: u32) -> u32

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: u32) -> u32

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: u32) -> u32

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: u32) -> (u32, u32)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: u32) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: u32) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: u32) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: u32) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: u32) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: u32) -> bool

Returns true if self >= other.

Source§

impl Cmp<u64>

Source

pub const fn total_cmp(self, other: u64) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: u64, max: u64) -> u64

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: u64) -> u64

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: u64) -> u64

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: u64) -> (u64, u64)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: u64) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: u64) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: u64) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: u64) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: u64) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: u64) -> bool

Returns true if self >= other.

Source§

impl Cmp<u128>

Source

pub const fn total_cmp(self, other: u128) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: u128, max: u128) -> u128

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: u128) -> u128

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: u128) -> u128

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: u128) -> (u128, u128)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: u128) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: u128) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: u128) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: u128) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: u128) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: u128) -> bool

Returns true if self >= other.

Source§

impl Cmp<usize>

Source

pub const fn total_cmp(self, other: usize) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: usize, max: usize) -> usize

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: usize) -> usize

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: usize) -> usize

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: usize) -> (usize, usize)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: usize) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: usize) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: usize) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: usize) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: usize) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: usize) -> bool

Returns true if self >= other.

Source§

impl Cmp<i8>

Source

pub const fn total_cmp(self, other: i8) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: i8, max: i8) -> i8

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: i8) -> i8

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: i8) -> i8

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: i8) -> (i8, i8)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: i8) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: i8) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: i8) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: i8) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: i8) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: i8) -> bool

Returns true if self >= other.

Source§

impl Cmp<i16>

Source

pub const fn total_cmp(self, other: i16) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: i16, max: i16) -> i16

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: i16) -> i16

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: i16) -> i16

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: i16) -> (i16, i16)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: i16) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: i16) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: i16) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: i16) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: i16) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: i16) -> bool

Returns true if self >= other.

Source§

impl Cmp<i32>

Source

pub const fn total_cmp(self, other: i32) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: i32, max: i32) -> i32

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: i32) -> i32

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: i32) -> i32

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: i32) -> (i32, i32)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: i32) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: i32) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: i32) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: i32) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: i32) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: i32) -> bool

Returns true if self >= other.

Source§

impl Cmp<i64>

Source

pub const fn total_cmp(self, other: i64) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: i64, max: i64) -> i64

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: i64) -> i64

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: i64) -> i64

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: i64) -> (i64, i64)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: i64) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: i64) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: i64) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: i64) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: i64) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: i64) -> bool

Returns true if self >= other.

Source§

impl Cmp<i128>

Source

pub const fn total_cmp(self, other: i128) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: i128, max: i128) -> i128

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: i128) -> i128

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: i128) -> i128

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: i128) -> (i128, i128)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: i128) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: i128) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: i128) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: i128) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: i128) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: i128) -> bool

Returns true if self >= other.

Source§

impl Cmp<isize>

Source

pub const fn total_cmp(self, other: isize) -> Ordering

Compares self and other using total order.

For integer types, ordering is already total; this method exists for consistency with floating-point comparisons.

Source

pub const fn clamp(self, min: isize, max: isize) -> isize

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: isize) -> isize

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: isize) -> isize

Compares and returns the minimum between self and other.

Source

pub const fn minmax(self, other: isize) -> (isize, isize)

Compares, orders and returns the (minimum, maximum) self and other.

Source

pub const fn eq(self, other: isize) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: isize) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: isize) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: isize) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: isize) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: isize) -> bool

Returns true if self >= other.

Source§

impl Cmp<f32>

Source

pub const fn total_cmp(self, other: f32) -> Ordering

A (const) port of f32::total_cmp.

Source

pub const fn clamp(self, min: f32, max: f32) -> f32

Compares and returns a clamped total ordered self between min and max.

§Examples
assert_eq![2.0, Cmp(5.0f32).clamp(-1.0, 2.0)];
assert_eq![-1.0, Cmp(-5.0f32).clamp(-1.0, 2.0)];
Source

pub const fn max(self, other: f32) -> f32

Compares and returns the total ordered maximum between self and other.

§Examples
assert_eq![2.0, Cmp(2.0f32).max(-1.0)];
assert_eq![2.0, Cmp(1.0f32).max(2.0)];
assert_eq![0.0, Cmp(-0.0f32).max(0.0)];
assert_eq![f32::INFINITY, Cmp(f32::INFINITY).max(f32::NEG_INFINITY)];
Source

pub const fn min(self, other: f32) -> f32

Compares and returns the total ordered minimum between self and other.

§Examples
assert_eq![-1.0, Cmp(2.0f32).min(-1.0)];
assert_eq![1.0, Cmp(1.0f32).min(2.0)];
assert_eq![-0.0, Cmp(-0.0f32).min(0.0)];
assert_eq![f32::NEG_INFINITY, Cmp(f32::INFINITY).min(f32::NEG_INFINITY)];
Source

pub const fn eq(self, other: f32) -> bool

Returns true if self == other using total order.

Source

pub const fn ne(self, other: f32) -> bool

Returns true if self != other using total order.

Source

pub const fn lt(self, other: f32) -> bool

Returns true if self < other using total order.

Source

pub const fn le(self, other: f32) -> bool

Returns true if self <= other using total order.

Source

pub const fn gt(self, other: f32) -> bool

Returns true if self > other using total order.

Source

pub const fn ge(self, other: f32) -> bool

Returns true if self >= other using total order.

Source

pub const fn is_positive(self) -> bool

Returns true if self is sign positive.

Source

pub const fn is_negative(self) -> bool

Returns true if self is sign negative.

Source

pub const fn is_infinite(self) -> bool

Returns true if self is infinite (either negative or positive).

Source

pub const fn is_finite(self) -> bool

Returns true if self is neither infinite nor NaN.

Source

pub const fn is_nan(self) -> bool

Returns true if self is NaN.

Source

pub const fn is_subnormal(self) -> bool

Returns true if self is subnormal.

Source

pub const fn is_normal(self) -> bool

Returns true if self is neither zero, infinite, subnormal, or NaN.

Source§

impl Cmp<f64>

Source

pub const fn total_cmp(self, other: f64) -> Ordering

A (const) port of f64::total_cmp.

Source

pub const fn clamp(self, min: f64, max: f64) -> f64

Compares and returns a clamped total ordered self between min and max.

§Examples
assert_eq![2.0, Cmp(5.0f64).clamp(-1.0, 2.0)];
assert_eq![-1.0, Cmp(-5.0f64).clamp(-1.0, 2.0)];
Source

pub const fn max(self, other: f64) -> f64

Compares and returns the total ordered maximum between self and other.

§Examples
assert_eq![2.0, Cmp(2.0f64).max(-1.0)];
assert_eq![2.0, Cmp(1.0f64).max(2.0)];
assert_eq![0.0, Cmp(-0.0f64).max(0.0)];
assert_eq![f64::INFINITY, Cmp(f64::INFINITY).max(f64::NEG_INFINITY)];
Source

pub const fn min(self, other: f64) -> f64

Compares and returns the total ordered minimum between self and other.

§Examples
assert_eq![-1.0, Cmp(2.0f64).min(-1.0)];
assert_eq![1.0, Cmp(1.0f64).min(2.0)];
assert_eq![-0.0, Cmp(-0.0f64).min(0.0)];
assert_eq![f64::NEG_INFINITY, Cmp(f64::INFINITY).min(f64::NEG_INFINITY)];
Source

pub const fn eq(self, other: f64) -> bool

Returns true if self == other using total order.

Source

pub const fn ne(self, other: f64) -> bool

Returns true if self != other using total order.

Source

pub const fn lt(self, other: f64) -> bool

Returns true if self < other using total order.

Source

pub const fn le(self, other: f64) -> bool

Returns true if self <= other using total order.

Source

pub const fn gt(self, other: f64) -> bool

Returns true if self > other using total order.

Source

pub const fn ge(self, other: f64) -> bool

Returns true if self >= other using total order.

Source

pub const fn is_positive(self) -> bool

Returns true if self is sign positive.

Source

pub const fn is_negative(self) -> bool

Returns true if self is sign negative.

Source

pub const fn is_infinite(self) -> bool

Returns true if self is infinite (either negative or positive).

Source

pub const fn is_finite(self) -> bool

Returns true if self is neither infinite nor NaN.

Source

pub const fn is_nan(self) -> bool

Returns true if self is NaN.

Source

pub const fn is_subnormal(self) -> bool

Returns true if self is subnormal.

Source

pub const fn is_normal(self) -> bool

Returns true if self is neither zero, infinite, subnormal, or NaN.

Source§

impl Cmp<f16>

Source

pub const fn total_cmp(self, other: f16) -> Ordering

A (const) port of f16::total_cmp.

Source

pub const fn clamp(self, min: f16, max: f16) -> f16

Compares and returns a clamped total ordered self between min and max.

§Examples
assert_eq![2.0, Cmp(5.0f16).clamp(-1.0, 2.0)];
assert_eq![-1.0, Cmp(-5.0f16).clamp(-1.0, 2.0)];
Source

pub const fn max(self, other: f16) -> f16

Compares and returns the total ordered maximum between self and other.

§Examples
assert_eq![2.0, Cmp(2.0f16).max(-1.0)];
assert_eq![2.0, Cmp(1.0f16).max(2.0)];
assert_eq![0.0, Cmp(-0.0f16).max(0.0)];
assert_eq![f16::INFINITY, Cmp(f16::INFINITY).max(f16::NEG_INFINITY)];
Source

pub const fn min(self, other: f16) -> f16

Compares and returns the total ordered minimum between self and other.

§Examples
assert_eq![-1.0, Cmp(2.0f16).min(-1.0)];
assert_eq![1.0, Cmp(1.0f16).min(2.0)];
assert_eq![-0.0, Cmp(-0.0f16).min(0.0)];
assert_eq![f16::NEG_INFINITY, Cmp(f16::INFINITY).min(f16::NEG_INFINITY)];
Source

pub const fn eq(self, other: f16) -> bool

Returns true if self == other using total order.

Source

pub const fn ne(self, other: f16) -> bool

Returns true if self != other using total order.

Source

pub const fn lt(self, other: f16) -> bool

Returns true if self < other using total order.

Source

pub const fn le(self, other: f16) -> bool

Returns true if self <= other using total order.

Source

pub const fn gt(self, other: f16) -> bool

Returns true if self > other using total order.

Source

pub const fn ge(self, other: f16) -> bool

Returns true if self >= other using total order.

Source

pub const fn is_positive(self) -> bool

Returns true if self is sign positive.

Source

pub const fn is_negative(self) -> bool

Returns true if self is sign negative.

Source

pub const fn is_infinite(self) -> bool

Returns true if self is infinite (either negative or positive).

Source

pub const fn is_finite(self) -> bool

Returns true if self is neither infinite nor NaN.

Source

pub const fn is_nan(self) -> bool

Returns true if self is NaN.

Source

pub const fn is_subnormal(self) -> bool

Returns true if self is subnormal.

Source

pub const fn is_normal(self) -> bool

Returns true if self is neither zero, infinite, subnormal, or NaN.

Source§

impl Cmp<f128>

Source

pub const fn total_cmp(self, other: f128) -> Ordering

A (const) port of f128::total_cmp.

Source

pub const fn clamp(self, min: f128, max: f128) -> f128

Compares and returns a clamped total ordered self between min and max.

§Examples
assert_eq![2.0, Cmp(5.0f128).clamp(-1.0, 2.0)];
assert_eq![-1.0, Cmp(-5.0f128).clamp(-1.0, 2.0)];
Source

pub const fn max(self, other: f128) -> f128

Compares and returns the total ordered maximum between self and other.

§Examples
assert_eq![2.0, Cmp(2.0f128).max(-1.0)];
assert_eq![2.0, Cmp(1.0f128).max(2.0)];
assert_eq![0.0, Cmp(-0.0f128).max(0.0)];
assert_eq![f128::INFINITY, Cmp(f128::INFINITY).max(f128::NEG_INFINITY)];
Source

pub const fn min(self, other: f128) -> f128

Compares and returns the total ordered minimum between self and other.

§Examples
assert_eq![-1.0, Cmp(2.0f128).min(-1.0)];
assert_eq![1.0, Cmp(1.0f128).min(2.0)];
assert_eq![-0.0, Cmp(-0.0f128).min(0.0)];
assert_eq![f128::NEG_INFINITY, Cmp(f128::INFINITY).min(f128::NEG_INFINITY)];
Source

pub const fn eq(self, other: f128) -> bool

Returns true if self == other using total order.

Source

pub const fn ne(self, other: f128) -> bool

Returns true if self != other using total order.

Source

pub const fn lt(self, other: f128) -> bool

Returns true if self < other using total order.

Source

pub const fn le(self, other: f128) -> bool

Returns true if self <= other using total order.

Source

pub const fn gt(self, other: f128) -> bool

Returns true if self > other using total order.

Source

pub const fn ge(self, other: f128) -> bool

Returns true if self >= other using total order.

Source

pub const fn is_positive(self) -> bool

Returns true if self is sign positive.

Source

pub const fn is_negative(self) -> bool

Returns true if self is sign negative.

Source

pub const fn is_infinite(self) -> bool

Returns true if self is infinite (either negative or positive).

Source

pub const fn is_finite(self) -> bool

Returns true if self is neither infinite nor NaN.

Source

pub const fn is_nan(self) -> bool

Returns true if self is NaN.

Source

pub const fn is_subnormal(self) -> bool

Returns true if self is subnormal.

Source

pub const fn is_normal(self) -> bool

Returns true if self is neither zero, infinite, subnormal, or NaN.

Source§

impl Cmp<Ordering>

Source

pub const fn total_cmp(self, other: Ordering) -> Ordering

Compares self and other using total order.

Ordering is already totally ordered as: Less < Equal < Greater.

Source

pub const fn clamp(self, min: Ordering, max: Ordering) -> Ordering

Compares and returns self clamped between min and max.

Source

pub const fn max(self, other: Ordering) -> Ordering

Compares and returns the maximum between self and other.

Source

pub const fn min(self, other: Ordering) -> Ordering

Compares and returns the minimum between self and other.

Source

pub const fn eq(self, other: Ordering) -> bool

Returns true if self == other.

Source

pub const fn ne(self, other: Ordering) -> bool

Returns true if self != other.

Source

pub const fn lt(self, other: Ordering) -> bool

Returns true if self < other.

Source

pub const fn le(self, other: Ordering) -> bool

Returns true if self <= other.

Source

pub const fn gt(self, other: Ordering) -> bool

Returns true if self > other.

Source

pub const fn ge(self, other: Ordering) -> bool

Returns true if self >= other.

Trait Implementations§

Source§

impl<T: Clone> Clone for Cmp<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ConstInit> ConstInit for Cmp<T>

Source§

const INIT: Self

Returns the compile-time “initial value” for a type.
Source§

impl<T: Copy> Copy for Cmp<T>

Source§

impl<T: Debug> Debug for Cmp<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Display> Display for Cmp<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq> Eq for Cmp<T>

Source§

impl<T: Ord> Ord for Cmp<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for Cmp<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for Cmp<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Cmp<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Cmp<T>
where T: RefUnwindSafe,

§

impl<T> Send for Cmp<T>
where T: Send,

§

impl<T> Sync for Cmp<T>
where T: Sync,

§

impl<T> Unpin for Cmp<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Cmp<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Cmp<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyExt for T
where T: Any + ?Sized,

Source§

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
Source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Source§

fn type_hash(&self) -> u64

Returns a deterministic hash of the TypeId of Self.
Source§

fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64

Returns a deterministic hash of the TypeId of Self using a custom hasher.
Source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Available on crate feature alloc only.
Upcasts Box<self> as Box<dyn Any>. Read more
Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_layout and non-crate feature safe_code only.
Returns some shared reference to the inner value if it is of type T. Read more
Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_layout and non-crate feature safe_code only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByteSized for T

Source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
Source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Hook for T

Source§

fn hook<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Hooks a mutation step into the value and returns it. Read more
Source§

fn tap<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Taps into the value for observation and returns it unchanged. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MemExt for T
where T: ?Sized,

Source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Source§

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Source§

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Source§

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Source§

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Source§

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Source§

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Source§

impl<T, R> Morph<R> for T
where T: ?Sized,

Source§

fn morph<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Morphs the value into a new one and returns it. Read more
Source§

fn morph_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Morphs the value by shared reference and returns the result. Read more
Source§

fn morph_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Morphs the value by exclusive reference and returns the result. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.