Crates.io | interva |
lib.rs | interva |
version | 0.1.3 |
source | src |
created_at | 2024-06-16 10:35:20.309502 |
updated_at | 2024-06-24 09:48:30.910792 |
description | A feature-rich crate for handling intervals. |
homepage | https://github.com/misaka10987/interva |
repository | https://github.com/misaka10987/interva |
max_upload_size | |
id | 1273426 |
size | 11,786 |
A feature-rich crate for handling intervals.
use interva::Interval;
// proper-subset
assert!(Interval::closed(1, 2) > Interval::open(1, 2));
// subset
assert!(Interval::<i32>::EMPTY <= Interval::EMPTY); // `i32`'s here just because type inference failed
// intersection
assert!(Interval::closed(1, 3) * Interval::open(2, 4) == Interval::lorc(2, 3)); // `lorc` for "left-open-right-closed"
// use `/` to judge whether contains certain element
assert!(Interval::closed(1.5, 1.7) / 1.7);
assert!(!(Interval::open(1.5, 1.7) / 1.7));
serde
for optional serialization support.