Improve documentation of std.array.replace and replaceInto

Note that `replace` doesn't have a `sink` parameter. And for `replaceInto`, `sink` must always be defined.
This commit is contained in:
Johan Engelen 2018-05-30 19:41:10 +02:00 committed by GitHub
parent e1cba41bd6
commit fcc5ac2102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2092,20 +2092,16 @@ if (isInputRange!RoR &&
/++ /++
Replace occurrences of `from` with `to` in `subject` in a new Replace occurrences of `from` with `to` in `subject` in a new array.
array. If `sink` is defined, then output the new array into
`sink`.
Params: Params:
sink = an $(REF_ALTTEXT output range, isOutputRange, std,range,primitives)
subject = the array to scan subject = the array to scan
from = the item to replace from = the item to replace
to = the item to replace all instances of `from` with to = the item to replace all instances of `from` with
Returns: Returns:
If `sink` isn't defined, a new array without changing the A new array without changing the contents of `subject`, or the original
contents of `subject`, or the original array if no match array if no match is found.
is found.
See_Also: See_Also:
$(REF substitute, std,algorithm,iteration) for a lazy replace. $(REF substitute, std,algorithm,iteration) for a lazy replace.
@ -2171,7 +2167,19 @@ if (isDynamicArray!(E[]) && isForwardRange!R1 && isForwardRange!R2
.replace([[0], [1, 2]], [[4]]) == [[4], [0], [3], [1, 2], [4]]); .replace([[0], [1, 2]], [[4]]) == [[4], [0], [3], [1, 2], [4]]);
} }
/// ditto /++
Replace occurrences of `from` with `to` in `subject` and output the result into
`sink`.
Params:
sink = an $(REF_ALTTEXT output range, isOutputRange, std,range,primitives)
subject = the array to scan
from = the item to replace
to = the item to replace all instances of `from` with
See_Also:
$(REF substitute, std,algorithm,iteration) for a lazy replace.
+/
void replaceInto(E, Sink, R1, R2)(Sink sink, E[] subject, R1 from, R2 to) void replaceInto(E, Sink, R1, R2)(Sink sink, E[] subject, R1 from, R2 to)
if (isOutputRange!(Sink, E) && isDynamicArray!(E[]) if (isOutputRange!(Sink, E) && isDynamicArray!(E[])
&& isForwardRange!R1 && isForwardRange!R2 && isForwardRange!R1 && isForwardRange!R2