mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
replace() and replaceFirst() don't return a copy of the array if nothing changed.
This behavior is reasonable and explicitly tested for in the unit tests, but previously, one could think that they always returned a copy from the docs.
This commit is contained in:
parent
cd5d266e04
commit
2d472caa80
1 changed files with 4 additions and 2 deletions
|
@ -1434,7 +1434,8 @@ unittest
|
|||
|
||||
/++
|
||||
Replace occurrences of $(D from) with $(D to) in $(D subject). Returns a new
|
||||
array without changing the contents of $(D subject).
|
||||
array without changing the contents of $(D subject), or the original array
|
||||
if no match is found.
|
||||
+/
|
||||
E[] replace(E, R1, R2)(E[] subject, R1 from, R2 to)
|
||||
if (isDynamicArray!(E[]) && isForwardRange!R1 && isForwardRange!R2
|
||||
|
@ -1745,7 +1746,8 @@ if (isDynamicArray!Range && is(ElementType!Range : T))
|
|||
|
||||
/++
|
||||
Replaces the first occurrence of $(D from) with $(D to) in $(D a). Returns a
|
||||
new array without changing the contents of $(D subject).
|
||||
new array without changing the contents of $(D subject), or the original
|
||||
array if no match is found.
|
||||
+/
|
||||
E[] replaceFirst(E, R1, R2)(E[] subject, R1 from, R2 to)
|
||||
if (isDynamicArray!(E[]) && isForwardRange!R1 && isInputRange!R2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue