Looks like map! is only defined for AbstractArray in the third argument.
Because you didn’t define its element type correctly :):
julia> @which eltype(typeof(wv))
eltype(::Type) in Base at abstractarray.jl:204
You need
function Base.eltype(::Type{<:WindowViewer{T,V}}) where {T,V}
return SubArray{T, 1, V, Tuple{UnitRange{Int64}}, true}
end
julia> @btime inplace_map!(Statistics.var, $var_x, $wv)
11.026 ms (0 allocations: 0 bytes)
julia> VERSION
v"1.8.2"
I think fixing the eltype takes care of the one allocation.