Skip to content

v1.2.0

Compare
Choose a tag to compare
@mcmah309 mcmah309 released this 10 Jul 00:53
· 194 commits to master since this release

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:

  1. RangeBounds can be used to get a Slice of an Arr, Slice, or List.
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.

  1. RangeBounds that also implement IterableRangeBounds 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.