forked from JuliaDiff/ChainRulesCore.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompat.jl
More file actions
23 lines (21 loc) · 674 Bytes
/
compat.jl
File metadata and controls
23 lines (21 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if VERSION < v"1.2"
Base.getproperty(x::Tuple, f::Int) = getfield(x, f)
end
if VERSION < v"1.1"
# Note: these are actually *better* than the ones in julia 1.1, 1.2, 1.3,and 1.4
# See: https://github.com/JuliaLang/julia/issues/34292
function fieldtypes(::Type{T}) where {T}
if @generated
ntuple(i -> fieldtype(T, i), fieldcount(T))
else
ntuple(i -> fieldtype(T, i), fieldcount(T))
end
end
function fieldnames(::Type{T}) where {T}
if @generated
ntuple(i -> fieldname(T, i), fieldcount(T))
else
ntuple(i -> fieldname(T, i), fieldcount(T))
end
end
end