Introducing Rangetools

84 points __rory

https://crates.io/crates/rangetools

Hiya.

Over the last couple years I've come across several posts lamenting the shortcomings of the standard library's range types. The goal here was to take a very "Itertools" approach, where you can just use rangetools::Rangetools; and get all of the functionality you need. So what kind of functionality is that?

Math: Intersection, Union, and Complement are supported right now, with much more to come.

Iterators: All of the types the crate introduces implement IntoIterator. One of the cool things about this is that the type system enforces things like "the intersection of a lower bounded range and an upper bounded range is a bounded range" so that you know at compile time whether or not the result is iterable, and just how iterable it is.

Copyable: I'm afraid I might have overstepped in making this choice, but the Rangetools trait is only implemented for ranges of T: Copy + Ord. It allows for the types introduced in the crate to be copyable (read: easily stored), will cover the vast majority of use cases, and it certainly made my life a lot easier.

While I've been working in rust for a couple years, this is the first crate I've published personally, and I'm equal parts excited and terrified to share it with the community. I would love to hear any critical feedback and feature requests if you'd like to slide into my github issues. Thanks for reading!

(Also did you see how many tests I wrote???)