File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ Use `Static(N)` instead of `Val(N)` when you want it to behave like a number.
66struct Static{N} <: Integer
77 Static {N} () where {N} = new {N::Int} ()
88end
9+
10+ const Zero = Static {0} ()
11+ const One = Static {1} ()
12+
913Base. @pure Static (N:: Int ) = Static {N} ()
1014Static (N:: Integer ) = Static (convert (Int, N))
1115Static (:: Static{N} ) where {N} = Static {N} ()
@@ -38,8 +42,8 @@ Base.iszero(::Static{0}) = true
3842Base. iszero (:: Static ) = false
3943Base. isone (:: Static{1} ) = true
4044Base. isone (:: Static ) = false
41- Base. zero (:: Type{T} ) where {T<: Static } = Static {0} ()
42- Base. one (:: Type{T} ) where {T<: Static } = Static {1} ()
45+ Base. zero (:: Type{T} ) where {T<: Static } = Zero
46+ Base. one (:: Type{T} ) where {T<: Static } = One
4347
4448for T = [:Real , :Rational , :Integer ]
4549 @eval begin
You can’t perform that action at this time.
0 commit comments