mirror of
https://github.com/dlang/phobos.git
synced 2025-05-04 17:11:26 +03:00
Fix dxml regression in multiple arguments skipOver
This commit is contained in:
parent
3aeec9b3e1
commit
eb6d449aa4
1 changed files with 17 additions and 1 deletions
|
@ -4073,8 +4073,9 @@ template skipOver(alias pred = (a, b) => a == b)
|
|||
{
|
||||
import std.algorithm.iteration : map;
|
||||
import std.algorithm.searching : minElement;
|
||||
import std.range : only;
|
||||
// Shortcut opportunity!
|
||||
if (needles.map!(a => a.length).minElement > haystack.length)
|
||||
if (needles.only.map!(a => a.length).minElement > haystack.length)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4353,6 +4354,21 @@ template skipOver(alias pred = (a, b) => a == b)
|
|||
assert(s2.skipOver("", "foo"));
|
||||
}
|
||||
|
||||
// dxml regression
|
||||
@safe unittest
|
||||
{
|
||||
import std.utf : byCodeUnit;
|
||||
import std.algorithm.comparison : equal;
|
||||
|
||||
bool stripStartsWith(Text)(ref Text text, string needle)
|
||||
{
|
||||
return text.skipOver(needle.byCodeUnit());
|
||||
}
|
||||
auto text = "<xml></xml>"d.byCodeUnit;
|
||||
assert(stripStartsWith(text, "<xml>"));
|
||||
assert(text.equal("</xml>"));
|
||||
}
|
||||
|
||||
/**
|
||||
Checks whether the given
|
||||
$(REF_ALTTEXT input range, isInputRange, std,range,primitives) starts with (one
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue