mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 16:40:48 +03:00
This commit is contained in:
parent
2c8d824173
commit
6462d38a07
2 changed files with 94 additions and 3 deletions
|
@ -3225,6 +3225,35 @@ unittest {
|
|||
assert(skipOver(s1, "Hell") && s1 == "o world");
|
||||
}
|
||||
|
||||
/* (Not yet documented.)
|
||||
Consume all elements from $(D r) that are equal to one of the elements
|
||||
$(D es).
|
||||
*/
|
||||
void skipAll(alias pred = "a == b", R, Es...)(ref R r, Es es)
|
||||
//if (is(typeof(binaryFun!pred(r1.front, es[0]))))
|
||||
{
|
||||
loop:
|
||||
for (; !r.empty; r.popFront())
|
||||
{
|
||||
foreach (i, E; Es)
|
||||
{
|
||||
if (binaryFun!pred(r.front, es[i]))
|
||||
{
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
//scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
auto s1 = "Hello world";
|
||||
skipAll(s1, 'H', 'e');
|
||||
assert(s1 == "llo world");
|
||||
}
|
||||
|
||||
/**
|
||||
The reciprocal of $(D startsWith).
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue