File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121# Base case -- if x is already a Vector{<:Real} there's no conversion necessary.
2222to_vec (x:: Vector{<:Real} ) = (x, identity)
2323
24+ # get around the outer constructors
25+ macro _force_construct (T, argsplat_ex)
26+ @assert argsplat_ex. head == :(... )
27+ args = first (argsplat_ex. args)
28+ return esc (Expr (:splatnew , T, args))
29+ end
30+
2431# Fallback method for `to_vec`. Won't always do what you wanted, but should be fine a decent
2532# chunk of the time.
2633function to_vec (x:: T ) where {T}
@@ -36,9 +43,9 @@ function to_vec(x::T) where {T}
3643 val_vecs = vals_from_vec (v)
3744 values = map ((b, v) -> b (v), backs, val_vecs)
3845 try
39- return T (values... )
46+ T (values... )
4047 catch MethodError
41- return T . name . wrapper ( values... )
48+ return @_force_construct (T, values... )
4249 end
4350 end
4451 return v, structtype_from_vec
You can’t perform that action at this time.
0 commit comments