Skip to main content

lset


Nathaniel
Okay, the next crate is called lset, which is data types for describing linear sets. And this is another one of those crates that we used a lot early on. And this one still does have some value, compared to primordial, although again, I don't know that we've been using it as much now as we used to use it. And basically what it is, is, these are two types line and span. And they're basically they're isomorphic with the range type. So if you know the range type in the standard Rust standard library, they're isomorphic with that. A line defines a linear array by a start point and an end point, right. So you have like the pointer of the start and the pointer to the end. And everything that's between is included in that set. The span is exactly the same thing, except it's defined as a start point and account rather than the start point and the end point. One other important thing that this does, that the range type does not do is that range does not copy, does not implement copy, which means that there's a variety of situations where it's really annoying to use. And the reason for that is that range is an iterator but these types are not iterators. Iterators can't be copy, because otherwise you may accidentally make a copy of the iterator and now you have two iterators, that you're iterating over. So it's not copy. These types are copy. But again, they're not bad if you want to use this in new code, I don't mind, but we also sort of haven't been really been using it as much. It's still probably useful. Great. But yeah.