Crates.io | ordered_vec |
lib.rs | ordered_vec |
version | 0.2.0 |
source | src |
created_at | 2023-01-04 15:46:21.884231 |
updated_at | 2023-01-05 00:24:37.846268 |
description | A trait that ensures that elements in a vector are pushed in a sorted order (both ascending and descending). |
homepage | |
repository | https://github.com/bwintertkb/ordered_vec |
max_upload_size | |
id | 750914 |
size | 13,991 |
This little library provides a trait that ensures elements in a vector are pushed in a sorted order, both ascending and descending.
use ordered_vec::OrdVec;
fn main() {
let mut values: Vec<i32> = Vec::new();
values.push_ord_ascending(5);
values.push_ord_ascending(3);
values.push_ord_ascending(7);
values.push_ord_ascending(1);
assert_eq!(values, [1, 3, 5, 7]);
let mut values: Vec<i32> = Vec::new();
values.push_ord_descending(5);
values.push_ord_descending(3);
values.push_ord_descending(7);
values.push_ord_descending(1);
assert_eq!(values, [7, 5, 3, 1]);
}
This library is licensed under MIT and Apache-2.0.