unwrap-ord

Crates.iounwrap-ord
lib.rsunwrap-ord
version0.1.3
sourcesrc
created_at2021-02-17 13:30:31.588891
updated_at2024-04-16 15:17:21.547337
descriptionWrapper type to easily convert Ord to PartialOrd. inspired by std::cmp::Reverse
homepage
repositoryhttps://github.com/higumachan/unwrap-ord
max_upload_size
id356459
size4,650
Yuta Hinokuma (higumachan)

documentation

README

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)]
}
Commit count: 14

cargo fmt