mirror of
https://github.com/dlang/phobos.git
synced 2025-05-12 07:08:48 +03:00
Add clarifications
This commit is contained in:
parent
cba0b3f813
commit
bbfe30a671
1 changed files with 18 additions and 9 deletions
|
@ -2908,6 +2908,11 @@ is propagated if no separator is specified.
|
||||||
See_also:
|
See_also:
|
||||||
$(REF chain, std,range), which chains a sequence of ranges with compatible elements
|
$(REF chain, std,range), which chains a sequence of ranges with compatible elements
|
||||||
into a single range.
|
into a single range.
|
||||||
|
|
||||||
|
Note:
|
||||||
|
When both outer and inner ranges of `RoR` are bidirectional and the joiner is
|
||||||
|
iterated from the back to the front, the separator will still be consumed from
|
||||||
|
front to back, even if it is a bidirectional range too.
|
||||||
*/
|
*/
|
||||||
auto joiner(RoR, Separator)(RoR r, Separator sep)
|
auto joiner(RoR, Separator)(RoR r, Separator sep)
|
||||||
if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
||||||
|
@ -3006,8 +3011,10 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
||||||
private void useSeparator()
|
private void useSeparator()
|
||||||
{
|
{
|
||||||
// Separator must always come after an item.
|
// Separator must always come after an item.
|
||||||
assert(_currentSep.empty && !_items.empty,
|
assert(_currentSep.empty,
|
||||||
"joiner: internal error");
|
"Attempting to reset a non-empty separator");
|
||||||
|
assert(!_items.empty,
|
||||||
|
"Attempting to use a separator in an empty joiner");
|
||||||
_items.popFront();
|
_items.popFront();
|
||||||
|
|
||||||
// If there are no more items, we're done, since separators are not
|
// If there are no more items, we're done, since separators are not
|
||||||
|
@ -3058,12 +3065,13 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
||||||
_current = _items.front;
|
_current = _items.front;
|
||||||
|
|
||||||
static if (isBidirectional)
|
static if (isBidirectional)
|
||||||
|
{
|
||||||
_currentBack = _items.back.save;
|
_currentBack = _items.back.save;
|
||||||
|
|
||||||
static if (isBidirectional)
|
|
||||||
{
|
|
||||||
if (_currentBack.empty)
|
if (_currentBack.empty)
|
||||||
{
|
{
|
||||||
|
// No data in the currentBack item - toggle to use
|
||||||
|
// the separator
|
||||||
inputEndsWithEmpty = true;
|
inputEndsWithEmpty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3073,9 +3081,8 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
||||||
// No data in the current item - toggle to use the separator
|
// No data in the current item - toggle to use the separator
|
||||||
inputStartsWithEmpty = true;
|
inputStartsWithEmpty = true;
|
||||||
|
|
||||||
//A range with a single element which is empty will always
|
// If RoR contains a single empty element,
|
||||||
// return an empty Result
|
// the returned Result will always be empty
|
||||||
|
|
||||||
import std.range : dropOne;
|
import std.range : dropOne;
|
||||||
static if (hasLength!RoR)
|
static if (hasLength!RoR)
|
||||||
{
|
{
|
||||||
|
@ -3186,8 +3193,10 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)
|
||||||
private void useBackSeparator()
|
private void useBackSeparator()
|
||||||
{
|
{
|
||||||
// Separator must always come after an item.
|
// Separator must always come after an item.
|
||||||
assert(_currentBackSep.empty && !_items.empty,
|
assert(_currentBackSep.empty,
|
||||||
"joiner: internal error");
|
"Attempting to reset a non-empty separator");
|
||||||
|
assert(!_items.empty,
|
||||||
|
"Attempting to use a separator in an empty joiner");
|
||||||
_items.popBack();
|
_items.popBack();
|
||||||
|
|
||||||
// If there are no more items, we're done, since separators are not
|
// If there are no more items, we're done, since separators are not
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue