Crates.io | range-ext |
lib.rs | range-ext |
version | 0.3.0 |
source | src |
created_at | 2019-06-06 07:17:03.510696 |
updated_at | 2023-09-05 21:29:51.513795 |
description | Range intersection |
homepage | https://github.com/AnickaBurova/range-ext |
repository | https://github.com/AnickaBurova/range-ext |
max_upload_size | |
id | 139320 |
size | 28,049 |
Range-Ext is a Rust library to handle range intersections. It provides a set of types and methods to determine whether and how two numeric ranges intersect.
Empty
, Overlap
, and Full
.Bellow
, BellowOverlap
, Within
, Same
, Over
, AboveOverlap
, Above
.To use Range-Ext in your Rust program, add it to your Cargo.toml
file:
use range_ext::{IntersectionExt, Intersect};
let range1 = 3..10;
let range2 = 5..8;
let intersection = range1.intersect(&range2);
Issue: I think there is a problem with intersecting Range, if either of the ranges have no ascending start to end. To make it work I have assumed I can reverse if they are descending, but that is causing the other to becaome RangeToInclusive, and that is not yet implemented. So dont have any descending ranges for now.
TODO: There is still missing RangeToInclusive at the moment.