#partial-ord

unwrap-ord

Wrapper type to easily convert Ord to PartialOrd. inspired by std::cmp::Reverse

4 releases

0.1.3 Apr 16, 2024
0.1.2 May 18, 2022
0.1.1 Feb 17, 2021
0.1.0 Feb 17, 2021

#508 in Rust patterns

Download history 41/week @ 2024-06-16 35/week @ 2024-06-23 59/week @ 2024-06-30 6/week @ 2024-07-14 1/week @ 2024-07-21 1/week @ 2024-08-11 5/week @ 2024-09-01 37/week @ 2024-09-22 18/week @ 2024-09-29

55 downloads per month

MIT license

4KB

unwrap-ord

Crates.io

Wrapper type to easily convert Ord to PartialOrd. inspired by std::cmp::Reverse

How to use

Add your Cargo.toml

unwrap-ord = "0.1.0"
use unwrap_ord::UnwrapOrd;

fn main() {
    let v = [1.0, 3.0, 2.0];
    let mut v: Vec<_> = v.iter().copied().map(|x| UnwrapOrd(x)).collect();

    v.sort();

    println!("{:?}", v);  // [UncheckOrd(1.0), UncheckOrd(2.0), UncheckOrd(3.0)]
}

No runtime deps