mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Add findSplitBefore example with an element using only()
Also remove typo.
This commit is contained in:
parent
08c587ead2
commit
ae6a8031cf
1 changed files with 8 additions and 1 deletions
|
@ -2809,7 +2809,7 @@ if (isForwardRange!R1 && isForwardRange!R2)
|
|||
assert(r[2] == "Sagan Memorial Station");
|
||||
auto r1 = findSplitBefore(a, "Sagan");
|
||||
assert(r1);
|
||||
assert(r1[0] == "Carl ", r1[0]);
|
||||
assert(r1[0] == "Carl ");
|
||||
assert(r1[1] == "Sagan Memorial Station");
|
||||
auto r2 = findSplitAfter(a, "Sagan");
|
||||
assert(r2);
|
||||
|
@ -2817,6 +2817,13 @@ if (isForwardRange!R1 && isForwardRange!R2)
|
|||
assert(r2[1] == " Memorial Station");
|
||||
}
|
||||
|
||||
/// Use $(REF only, std,range) to find single elements:
|
||||
@safe pure nothrow unittest
|
||||
{
|
||||
import std.range : only;
|
||||
assert([1, 2, 3, 4].findSplitBefore(only(3))[0] == [1, 2]);
|
||||
}
|
||||
|
||||
@safe pure nothrow unittest
|
||||
{
|
||||
import std.range.primitives : empty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue