rangemap icon indicating copy to clipboard operation
rangemap copied to clipboard

Generalize to all RangeBounds impls?

Open Kinrany opened this issue 5 months ago • 3 comments

Superficially it seems like the rangemap type could be generic over the range types by using standard RangeBounds. This would allow both dropping RangeMapInclusive and using custom range types.

The main reason for having custom range types is the well-known design flaws of the standard range types, such as not being Copy.

For a specific use case, I have a collection of various date, time and datetime ranges that rely on chrono and provide extra utility functions.

Has this been explored?

Kinrany avatar Jul 26 '25 06:07 Kinrany

I think I explored it 3 years ago with #56 and #57.

It resulted in me making a new crate for it called nodit if you want to have a look.

ripytide avatar Jul 26 '25 11:07 ripytide

I am at least in principle open to something along these lines, but in practice I am unlikely to explore it any time soon due to $LIFE time constraints.

One complication I see is that we currently have tighter bounds on K for RangeInclusiveMap, because it needs to be able to tell whether two values are immediately adjacent. RangeMap does not have this need. So having one type that accepts arbitrary range bounds without imposing unnecessary trait bounds on the keys is... tricky.

jeffparsons avatar Jul 27 '25 22:07 jeffparsons

Do you remember the full list of things that are missing from RangeBounds? The ability to to find a successor/predecessor, one that types like floating point numbers or fractional timestamps may not have? Anything else?

Kinrany avatar Jul 28 '25 16:07 Kinrany