Crates.io | impartial-ord |
lib.rs | impartial-ord |
version | 1.0.6 |
created_at | 2023-03-01 21:20:55.108641+00 |
updated_at | 2024-06-15 12:10:37.942743+00 |
description | Derives a quicker PartialOrd for types that already implement Ord |
homepage | |
repository | https://github.com/Alorel/impartial-ord-rs |
max_upload_size | |
id | 798328 |
size | 5,275 |
Derives a quicker PartialOrd
for types that already implement Ord
.
#[derive(impartial_ord::ImpartialOrd, Ord, PartialEq, Eq, Default, Debug)]
struct MyStruct { foo: Bar, qux: Baz, }
assert_eq!(MyStruct::default().partial_cmp(&MyStruct::default()), Some(Ordering::Equal));
impl PartialOrd for MyStruct where Self: Ord {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(Ord::cmp(self, other))
}
}