an output range
the array to scan
the item to replace
the item to replace all instances of from with
auto arr = [1, 2, 3, 4, 5]; auto from = [2, 3]; auto to = [4, 6]; auto sink = appender!(int[])(); replaceInto(sink, arr, from, to); assert(sink.data == [1, 4, 6, 4, 5]);
std.algorithm.iteration.substitute for a lazy replace.
Replace occurrences of from with to in subject and output the result into sink.