Interval_map in rust?


#1

Hello my fellow rustaceans!

I’m currently looking for one (or several) crates that would provide the same containers than boost::icl.
In particular, I would need an interval_map that would exhibit the following behavior:

let mut map = IntervalMap::new();
let duration = Duration::from_hours(8, 11);
let people = hashset!({"John", "Denis"}); 
map.insert(duration, people); // map contains {{8, 11} -> {"John", "Denis"}}

let duration = Duration::from_hours(9, 12);
let people = hashset!({"Katie"});
map.insert(duration, people); // map contains {{8, 9} -> {"John", "Denis"}, {9, 11} -> {"John", "Denis", "Katie"}, {11, 12} -> {"Katie"}}

The exact API is not relevant, what matters is the “join” semantics.
I would vastly prefer a container that would be generic, allowing me to use custom types for the interval, like boost::icl does.

I tried to look on crates.io, but the only crate I found was intervallum, which only works with numeric ranges and does not provide an interval_map.

Any suggestions? Thank you for reading.