Is there a way to avoid allocating memory when using Chain.jl or pipeing? Technica

Is there a way to avoid allocating memory when using Chain.jl or pipeing? Technically these are type stable and can mutate the original array to avoid allocation

julia> @time @chain x begin
           _ * 1
       end;
  0.002212 seconds (2 allocations: 7.629 MiB)

julia> @time @chain x begin
           _ * 1
           _ * 1
       end;
  0.008802 seconds (4 allocations: 15.259 MiB)

Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message :slack:) (More Info)

You could use rmul! to overwrite the chained array

Linear Algebra ยท The Julia Language!

@chain x begin
    rmul!(2)
end

Or overwrite it like this I guess. At some point you loose the benefit of chaining syntax for stuff like this

@chain x begin
   _ .*= 1
end