@@ -113,15 +113,15 @@ function Base.IndexStyle(::Type{S}) where {S<:StructArray}
113
113
index_type (S) === Int ? IndexLinear () : IndexCartesian ()
114
114
end
115
115
116
- function _undef_array (:: Type{T} , sz; unwrap = t -> false ) where {T}
116
+ function _undef_array (:: Type{T} , sz; unwrap:: F = alwaysfalse ) where {T, F }
117
117
if unwrap (T)
118
118
return StructArray {T} (undef, sz; unwrap = unwrap)
119
119
else
120
120
return Array {T} (undef, sz)
121
121
end
122
122
end
123
123
124
- function _similar (v:: AbstractArray , :: Type{Z} ; unwrap = t -> false ) where {Z}
124
+ function _similar (v:: AbstractArray , :: Type{Z} ; unwrap:: F = alwaysfalse ) where {Z, F }
125
125
if unwrap (Z)
126
126
return buildfromschema (typ -> _similar (v, typ; unwrap = unwrap), Z)
127
127
else
@@ -149,12 +149,12 @@ julia> StructArray{ComplexF64}(undef, (2,3))
149
149
"""
150
150
StructArray (:: Base.UndefInitializer , sz:: Dims )
151
151
152
- function StructArray {T} (:: Base.UndefInitializer , sz:: Dims ; unwrap = t -> false ) where {T}
152
+ function StructArray {T} (:: Base.UndefInitializer , sz:: Dims ; unwrap:: F = alwaysfalse ) where {T, F }
153
153
buildfromschema (typ -> _undef_array (typ, sz; unwrap = unwrap), T)
154
154
end
155
- StructArray {T} (u:: Base.UndefInitializer , d:: Integer... ; unwrap = t -> false ) where {T} = StructArray {T} (u, convert (Dims, d); unwrap = unwrap)
155
+ StructArray {T} (u:: Base.UndefInitializer , d:: Integer... ; unwrap:: F = alwaysfalse ) where {T, F } = StructArray {T} (u, convert (Dims, d); unwrap = unwrap)
156
156
157
- function similar_structarray (v:: AbstractArray , :: Type{Z} ; unwrap = t -> false ) where {Z}
157
+ function similar_structarray (v:: AbstractArray , :: Type{Z} ; unwrap:: F = alwaysfalse ) where {Z, F }
158
158
buildfromschema (typ -> _similar (v, typ; unwrap = unwrap), Z)
159
159
end
160
160
@@ -203,11 +203,11 @@ julia> StructArray((1, Complex(i, j)) for i = 1:3, j = 2:4; unwrap = T -> !(T<:R
203
203
(1, 3+2im) (1, 3+3im) (1, 3+4im)
204
204
```
205
205
"""
206
- function StructArray (v; unwrap = t -> false ):: StructArray
206
+ function StructArray (v; unwrap:: F = alwaysfalse ):: StructArray where {F}
207
207
collect_structarray (v; initializer = StructArrayInitializer (unwrap))
208
208
end
209
209
210
- function StructArray (v:: AbstractArray{T} ; unwrap = t -> false ) where {T}
210
+ function StructArray (v:: AbstractArray{T} ; unwrap:: F = alwaysfalse ) where {T, F }
211
211
s = similar_structarray (v, T; unwrap = unwrap)
212
212
for i in eachindex (v)
213
213
@inbounds s[i] = v[i]
0 commit comments