Why should FullRange have dedicated syntax?
Because the other range types have dedicated syntax and are usable as first-class values in custom APIs. Not having FullRange is inconsistent.
Motivation
Slicing syntax is neat, it gives us ranges and slices using one syntax device, ...
We can already use the Range, RangeTo, RangeFrom values to create custom interfaces:
trait AnyRange<Idx> {
// Imagine all the Range types implement this trait
}
struct Mat {
data: Vec<f32>
}
impl Mat {
fn slice<R, S>(&self, xs: R, ys: S) -> Mat where
R: AnyRange<uint>, S: AnyRange<uint>
{
// Implement 2D slicing here.
// Maybe the type is even CoW and returns a view transparently?
}
}
With the slice syntax, we can implement things like:
let m = Mat::new(...)
let submatrix = m.slice(1.., 1..);
But FullRange is missing syntax! We can’t do this today:
let submatrix = m.slice(1.., ..);
Workarounds?
We can use 0.. instead of .., in almost all cases.