mirror of
https://github.com/dlang/phobos.git
synced 2025-05-07 03:27:03 +03:00
Fix issue 15735: Correct splitter documentation when argument is an empty range.
This commit is contained in:
parent
29a629eb26
commit
c6ef7c3f5e
1 changed files with 5 additions and 3 deletions
|
@ -3663,9 +3663,8 @@ empty elements.
|
||||||
The predicate is passed to $(REF binaryFun, std,functional), and can either accept
|
The predicate is passed to $(REF binaryFun, std,functional), and can either accept
|
||||||
a string, or any callable that can be executed via $(D pred(element, s)).
|
a string, or any callable that can be executed via $(D pred(element, s)).
|
||||||
|
|
||||||
If the empty range is given, the result is a range with one empty
|
If the empty range is given, the result is an empty range. If a range with
|
||||||
element. If a range with one separator is given, the result is a range
|
one separator is given, the result is a range with two empty elements.
|
||||||
with two empty elements.
|
|
||||||
|
|
||||||
If splitting a string on whitespace and token compression is desired,
|
If splitting a string on whitespace and token compression is desired,
|
||||||
consider using $(D splitter) without specifying a separator (see fourth overload
|
consider using $(D splitter) without specifying a separator (see fourth overload
|
||||||
|
@ -3852,6 +3851,7 @@ if (is(typeof(binaryFun!pred(r.front, s)) : bool)
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.algorithm.comparison : equal;
|
import std.algorithm.comparison : equal;
|
||||||
|
import std.range : empty;
|
||||||
|
|
||||||
assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ]));
|
assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ]));
|
||||||
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];
|
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];
|
||||||
|
@ -3863,6 +3863,8 @@ if (is(typeof(binaryFun!pred(r.front, s)) : bool)
|
||||||
assert(equal(splitter(a, 0), [ [], [1] ]));
|
assert(equal(splitter(a, 0), [ [], [1] ]));
|
||||||
w = [ [0], [1], [2] ];
|
w = [ [0], [1], [2] ];
|
||||||
assert(equal(splitter!"a.front == b"(w, 1), [ [[0]], [[2]] ]));
|
assert(equal(splitter!"a.front == b"(w, 1), [ [[0]], [[2]] ]));
|
||||||
|
assert(splitter("", '.').empty);
|
||||||
|
assert(equal(splitter(".", '.'), [ "", "" ]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue