1- import StaticArrays: StaticArray, tuple_prod
1+ import StaticArrays: StaticArray, FieldArray, tuple_prod
22
33"""
44 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
88julia> StructArrays.staticschema(SVector{2, Float64})
99Tuple{Float64, Float64}
1010```
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`.
1114"""
1215@generated function StructArrays. staticschema (:: Type{<:StaticArray{S, T}} ) where {S, T}
1316 return quote
@@ -17,3 +20,10 @@ Tuple{Float64, Float64}
1720end
1821StructArrays. createinstance (:: Type{T} , args... ) where {T<: StaticArray } = T (args)
1922StructArrays. 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