Skip to content

Commit 921bdcd

Browse files
authored
Add SUnitRange(::Int, ::Int) constructor and doc string (#223)
1 parent 1966706 commit 921bdcd

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "3.1.37"
3+
version = "3.1.38"
44

55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ ArrayInterface.LazyAxis
8282
ArrayInterface.OptionallyStaticStepRange
8383
ArrayInterface.OptionallyStaticUnitRange
8484
ArrayInteraface.SOneTo
85+
ArrayInteraface.SUnitRange
8586
ArrayInterface.StrideIndex
8687
```
8788

src/ranges.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ end
188188
end
189189
end
190190

191+
"""
192+
SUnitRange(start::Int, stop::Int)
193+
194+
An alias for `OptionallyStaticUnitRange` where both the start and stop are known statically.
195+
"""
191196
const SUnitRange{F,L} = OptionallyStaticUnitRange{StaticInt{F},StaticInt{L}}
197+
SUnitRange(start::Int, stop::Int) = SUnitRange{start,stop}()
192198

193199
"""
194200
SOneTo(n::Int)

test/ranges.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@test @inferred(static(1):2:10) == 1:2:10
1313
@test @inferred(static(1):UInt(10)) === static(1):10
1414
@test @inferred(UInt(1):static(1):static(10)) === 1:static(10)
15+
@test ArrayInterface.SUnitRange(1, 10) == 1:10
1516
@test @inferred(ArrayInterface.OptionallyStaticUnitRange{Int,Int}(1:10)) == 1:10
1617
@test @inferred(ArrayInterface.OptionallyStaticUnitRange(1:10)) == 1:10
1718

0 commit comments

Comments
 (0)