#partial-ord #ord #reverse #wrapper-type

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

#522 in Rust patterns

Download history 17/week @ 2024-09-19 28/week @ 2024-09-26 28/week @ 2024-10-03 14/week @ 2024-10-10 14/week @ 2024-10-17 40/week @ 2024-10-24 37/week @ 2024-10-31 67/week @ 2024-11-07 230/week @ 2024-11-14 217/week @ 2024-11-21 3/week @ 2024-11-28 14/week @ 2024-12-05 56/week @ 2024-12-12 11/week @ 2024-12-19 118/week @ 2024-12-26 46/week @ 2025-01-02

233 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