It is recommended to use unit ranges to construct CartesianIndices, but isn’t it better to use CartesianIndex all the way down? Transforming to UnitRange make the code not quite clean.
julia> c1 = CartesianIndex((2,2))
CartesianIndex(2, 2)
julia> c2 = CartesianIndex((4,5))
CartesianIndex(4, 5)
julia> CartesianIndices(c1,c2)
┌ Warning: the internal representation of CartesianIndices has changed, use `CartesianIndices((2:4, 2:
5))` (or other more appropriate AbstractUnitRange type) instead.
│ caller = top-level scope at none:0
└ @ Core none:0
3×4 CartesianIndices{2,Tuple{UnitRange{Int64},UnitRange{Int64}}}:
CartesianIndex(2, 2) CartesianIndex(2, 3) CartesianIndex(2, 4) CartesianIndex(2, 5)
CartesianIndex(3, 2) CartesianIndex(3, 3) CartesianIndex(3, 4) CartesianIndex(3, 5)
CartesianIndex(4, 2) CartesianIndex(4, 3) CartesianIndex(4, 4) CartesianIndex(4, 5)