Skip to content

Commit 4fc2d6f

Browse files
authored
Merge pull request #73 from Tokazama/StaticInt-constructor
Additional StaticInt constructor
2 parents a68ae8e + e1811b3 commit 4fc2d6f

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-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 = "2.13.1"
3+
version = "2.13.2"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/static.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ StaticInt(::StaticInt{N}) where {N} = StaticInt{N}()
1616
StaticInt(::Val{N}) where {N} = StaticInt{N}()
1717
# Base.Val(::StaticInt{N}) where {N} = Val{N}()
1818
Base.convert(::Type{T}, ::StaticInt{N}) where {T<:Number,N} = convert(T, N)
19+
(::Type{T})(x) where {T<:StaticInt} = StaticInt(x)
1920
# (::Type{T})(::ArrayInterface.StaticInt{N}) where {T,N} = T(N)
2021
Base.convert(::Type{StaticInt{N}}, ::StaticInt{N}) where {N} = StaticInt{N}()
2122

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ end
400400
@testset "Static" begin
401401
@test iszero(StaticInt(0))
402402
@test !iszero(StaticInt(1))
403+
@test @inferred(one(StaticInt(1))) === StaticInt(1)
404+
@test @inferred(zero(StaticInt(1))) === StaticInt(0)
403405
@test @inferred(one(StaticInt)) === StaticInt(1)
404406
@test @inferred(zero(StaticInt)) === StaticInt(0)
405407
@test eltype(one(StaticInt)) <: Int

0 commit comments

Comments
 (0)