Struct konst::polymorphism::CmpWrapper[][src]

pub struct CmpWrapper<T>(pub T);
This is supported on crate feature cmp only.
Expand description

A wrapper type for std types, which defines const_eq and const_cmp methods for them.

This is what coerce_to_cmp and the comparison macros convert standard library types into.

Example

use konst::{
    polymorphism::CmpWrapper,
    coerce_to_cmp,
};

use std::cmp::Ordering;

{
    // The `CmpWrapper<u32>` type annotation is just for the reader
    let foo: CmpWrapper<u32> = coerce_to_cmp!(10u32);
    assert!( foo.const_eq(&10));
    assert!(!foo.const_eq(&20));
     
    assert_eq!(foo.const_cmp(&5), Ordering::Greater);
    assert_eq!(foo.const_cmp(&10), Ordering::Equal);
    assert_eq!(foo.const_cmp(&15), Ordering::Less);
}
{
    let bar = CmpWrapper(Ordering::Equal);
    assert!( bar.const_eq(&Ordering::Equal));
    assert!(!bar.const_eq(&Ordering::Less));
     
    assert_eq!(bar.const_cmp(&Ordering::Less), Ordering::Greater);
    assert_eq!(bar.const_cmp(&Ordering::Equal), Ordering::Equal);
    assert_eq!(bar.const_cmp(&Ordering::Greater), Ordering::Less);
}

Tuple Fields

0: T

Implementations

For constructing from a reference to an array.

With slices you can do CmpWrapper(slice) as well.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Compares self and other for equality.

Compares self and other for ordering.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

What kind of type this is, this can be one of: Read more

The type after dereferencing, implemented as type This = Self; for all non-reference types Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.