v1.2.0
Slice<T>
now implements List<T>
New RangeBounds
RangeBounds
works the same as Rust's RangeBounds
(usually seen as syntactic sugar e.g. 1..=3
)
They have two uses:
RangeBounds
can be used to get aSlice
of anArr
,Slice
, orList
.
void func(RangeBounds bounds) {
Arr<int> arr = Arr.range(0, 10);
Slice<int> slice = arr(bounds);
expect(slice, equals([4, 5, 6, 7, 8, 9]));
}
func(RangeFrom(4));
The variants are Range
, RangeFrom
, RangeFull
, RangeInclusive
, RangeTo
, and RangeToInclusive
.
RangeBounds
that also implementIterableRangeBounds
can be iterated over as a generator.
for(int x in Range(5, 10)){ // 5, 6, 7, 8, 9
// code
}
All RangeBounds
can be const
.