-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Every std::ops::Range* struct implements std::ops::RangeBounds, which holds the endpoints of the range. The endpoints are std::ops::Bound<t>s:
pub enum Bound<T> {
Included(T),
Excluded(T),
Unbounded,
}Every possible kind of interval can be represented with this machinery: open, closed, half-open, unbounded on either or both ends, even degenerate intervals (singletons and null sets).
An argument against supporting anything other than inclusive ranges is, every numeric type is finite (including floats), and thus the topology of the type is discrete. In other words, for, say, floats, the half-open set [a, b) is precisely the same set as [a, b'] where b' is the largest representable float smaller than b.
My counterargument is that we use these sets to approximate continuous intervals and want them to have the semantics of the usual continuous topology on the reals. In other words, we wish to interpret [a, b) to include all of the numbers between b' and b, despite b being potentially approximate.