Regardless of how range syntax will eventually work, the underlying data structure needs to support both inclusive and exclusive ranges. Therefore, I propose (as others have, IIRC) that the structure be changed to:
pub enum Bound<T> {
Inclusive(T),
Exclusive(T),
}
pub struct Range<T> {
pub start: Bound<T>,
pub end: Bound<T>,
}
pub struct RangeFrom<T> {
pub start: Bound<T>,
}
pub struct RangeTo<T> {
pub end: Bound<T>,
}
pub struct RangeFull;
My motivation is that Range is a very useful primitive and I don’t want to end up in a situation where libraries start defining their own ranges because they need inclusive boundaries.
My specific use case is that I would like to replace the rand crate’s custom Range with a standard Range.