Crates.io | classific |
lib.rs | classific |
version | 0.1.4 |
source | src |
created_at | 2020-06-27 12:50:37.826618 |
updated_at | 2020-06-27 17:09:45.326427 |
description | Classifications, comparator and equivalence class implementations |
homepage | |
repository | https://github.com/pozs/classific |
max_upload_size | |
id | 258722 |
size | 34,272 |
A Rust library for classifications like comparators and equivalence classes.
Links:
Add this to your Cargo.toml
:
[dependencies]
classific = "0.1"
use classific::{Comparator, EqClass, comparing_with, reverse_order, eq_by};
#[derive(PartialEq, Eq, Debug)]
struct Person<'a> {
name: &'a str,
age: u8,
}
fn main() {
let foo = Person {
name: "Foo",
age: 32,
};
let bar = Person {
name: "Bar",
age: 32,
};
assert!(eq_by(|p: &Person| p.age).eq(&foo, &bar));
assert_eq!(comparing_with(|p: &Person| p.name, reverse_order()).max(&foo, &bar), &bar);
}