1
- import StaticArrays: StaticArray, tuple_prod
1
+ import StaticArrays: StaticArray, FieldArray, tuple_prod
2
2
3
3
"""
4
4
StructArrays.staticschema(::Type{<:StaticArray{S, T}}) where {S, T}
@@ -8,6 +8,9 @@ The `staticschema` of a `StaticArray` element type is the `staticschema` of the
8
8
julia> StructArrays.staticschema(SVector{2, Float64})
9
9
Tuple{Float64, Float64}
10
10
```
11
+ The one exception to this rule is `<:StaticArrays.FieldArray`, since `FieldArray` is based on a
12
+ struct. In this case, `staticschema(<:FieldArray)` returns the `staticschema` for the struct
13
+ which subtypes `FieldArray`.
11
14
"""
12
15
@generated function StructArrays. staticschema (:: Type{<:StaticArray{S, T}} ) where {S, T}
13
16
return quote
@@ -17,3 +20,10 @@ Tuple{Float64, Float64}
17
20
end
18
21
StructArrays. createinstance (:: Type{T} , args... ) where {T<: StaticArray } = T (args)
19
22
StructArrays. component (s:: StaticArray , i) = getindex (s, i)
23
+
24
+ # invoke general fallbacks for a `FieldArray` type.
25
+ @inline function StructArrays. staticschema (T:: Type{<:FieldArray} )
26
+ invoke (StructArrays. staticschema, Tuple{Type{<: Any }}, T)
27
+ end
28
+ StructArrays. component (s:: FieldArray , i) = invoke (StructArrays. component, Tuple{Any, Any}, s, i)
29
+ StructArrays. createinstance (T:: Type{<:FieldArray} , args... ) = invoke (createinstance, Tuple{Type{<: Any }, Vararg}, T, args... )
0 commit comments