CmpExt

Trait CmpExt 

Source
pub trait CmpExt {
    // Required method
    fn cmp_ext(&self, other: &Self) -> Ordering;
}
Expand description

Extension trait for comparison operations that works with both ordered and floating-point types.

This trait provides a unified interface for comparison operations across different numeric types, handling the special case of floating-point numbers which don’t implement Ord due to NaN values.

Required Methods§

Source

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

Compare two values, returning their ordering.

For integer types, this uses the standard cmp method. For floating-point types, this uses total_cmp to handle NaN values consistently.

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.

Implementations on Foreign Types§

Source§

impl CmpExt for f32

Source§

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

Source§

impl CmpExt for f64

Source§

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

Source§

impl CmpExt for i8

Source§

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

Source§

impl CmpExt for i16

Source§

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

Source§

impl CmpExt for i32

Source§

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

Source§

impl CmpExt for i64

Source§

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

Source§

impl CmpExt for i128

Source§

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

Source§

impl CmpExt for isize

Source§

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

Source§

impl CmpExt for u8

Source§

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

Source§

impl CmpExt for u16

Source§

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

Source§

impl CmpExt for u32

Source§

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

Source§

impl CmpExt for u64

Source§

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

Source§

impl CmpExt for u128

Source§

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

Source§

impl CmpExt for usize

Source§

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

Implementors§