I might have missed something in StaticArrays.jl
. Is there an agreed type which can contain the length/multidimensional size of an iterator, either statically or dynamically, and which can be used to collect into either a plain Array
or a StaticArray
? I could write something like this:
struct StaticCollector{N,D} end # D is a `Tuple` of static dimensions
struct DynamicCollector{N}
dims::NTuple{N,Int}
end
Base.collect(::StaticCollector{N,D}, itr) =
StaticArrays.sacollect(StaticArray{N,D}, #= etc...=#)
Base.collect(::DynamicCollector, itr) = collect(itr)
but this particular wheel has likely already been invented (and my implementation would of course be much worse than any existing one). Did I miss something?