Crates.io | stdng |
lib.rs | stdng |
version | 0.1.6 |
source | src |
created_at | 2023-12-26 02:25:43.475403 |
updated_at | 2024-02-24 01:53:21.594706 |
description | An enhancement for Rust standard library |
homepage | |
repository | https://github.com/xflops/stdng |
max_upload_size | |
id | 1080573 |
size | 18,241 |
The enhancement of Rust stand library
use std::cmp::Ordering;
use stdng::collections::BinaryHeap;
struct IntCmpR {}
impl Cmp<i32> for IntCmpR {
fn cmp(&self, t1: &i32, t2: &i32) -> Ordering {
match t1.cmp(t2) {
Ordering::Greater => Ordering::Less,
Ordering::Less => Ordering::Greater,
Ordering::Equal => Ordering::Equal,
}
}
}
fn main() {
let mut head = BinaryHeap::new(IntCmpR {});
head.push(1);
head.push(2);
let i = head.pop();
assert_eq!(Some(1), i);
}