Crates.io | unwrap-ord |
lib.rs | unwrap-ord |
version | 0.1.3 |
source | src |
created_at | 2021-02-17 13:30:31.588891 |
updated_at | 2024-04-16 15:17:21.547337 |
description | Wrapper type to easily convert Ord to PartialOrd. inspired by std::cmp::Reverse |
homepage | |
repository | https://github.com/higumachan/unwrap-ord |
max_upload_size | |
id | 356459 |
size | 4,650 |
Wrapper type to easily convert Ord to PartialOrd. inspired by std::cmp::Reverse
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)]
}