mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
fix issue 12470 - std.array.replace does not work with inout(char)[]
This commit is contained in:
parent
bb1e6f9d50
commit
722ecd878c
1 changed files with 11 additions and 1 deletions
|
@ -1887,7 +1887,7 @@ if (isForwardRange!R1 && isForwardRange!R2
|
||||||
Select!(haystack[0].sizeof == 1, ubyte[],
|
Select!(haystack[0].sizeof == 1, ubyte[],
|
||||||
Select!(haystack[0].sizeof == 2, ushort[], uint[]));
|
Select!(haystack[0].sizeof == 2, ushort[], uint[]));
|
||||||
// Will use the array specialization
|
// Will use the array specialization
|
||||||
static TO force(TO, T)(T r) @trusted { return cast(TO) r; }
|
static TO force(TO, T)(inout T r) @trusted { return cast(TO) r; }
|
||||||
return force!R1(.find!(pred, Representation, Representation)
|
return force!R1(.find!(pred, Representation, Representation)
|
||||||
(force!Representation(haystack), force!Representation(needle)));
|
(force!Representation(haystack), force!Representation(needle)));
|
||||||
}
|
}
|
||||||
|
@ -2096,6 +2096,16 @@ if (isForwardRange!R1 && isForwardRange!R2
|
||||||
assert([C(1,0), C(2,0), C(3,1), C(4,0)].find!"a.x == b"(SList!int(2, 3)[]) == [C(2,0), C(3,1), C(4,0)]);
|
assert([C(1,0), C(2,0), C(3,1), C(4,0)].find!"a.x == b"(SList!int(2, 3)[]) == [C(2,0), C(3,1), C(4,0)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@safe unittest // issue 12470
|
||||||
|
{
|
||||||
|
import std.array : replace;
|
||||||
|
inout(char)[] sanitize(inout(char)[] p)
|
||||||
|
{
|
||||||
|
return p.replace("\0", " ");
|
||||||
|
}
|
||||||
|
assert(sanitize("O\x00o") == "O o");
|
||||||
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm.comparison : equal;
|
import std.algorithm.comparison : equal;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue