Current behaviour:
void main()
{
import std.algorithm;
assert("one two three".until("two", OpenRight.no).equal("one t"));
}
It's probably safe to say the user expected the result to be equal "one two". Range sentinel values aren't in the tests, so it's probably safe to say `until` was not designed with range sentinels in mind.
Comment #1 by greensunny12 — 2018-02-09T20:30:10Z
Agreed. Any idea how we can fix this without breaking code? Do we need to introduce a special enum?
OpenRight {
yes,
no,
full
}
Comment #2 by snarwin+bugzilla — 2022-09-14T22:33:53Z
It's possible to get the desired result here using `findSplit`:
---
void main()
{
import std.algorithm, std.range;
auto result = "one two three".findSplit("two").expand[0 .. $-1].chain;
assert(result.equal("one two"));
}
---
Comment #3 by dlang-bot — 2022-09-16T06:35:46Z
@jamesragray updated dlang/phobos pull request #8568 "Issue 14543 std.algorithm.searching.until does not handle range sentinels nicely" fixing this issue:
- Fix issue 14543: std.algorithm.searching.until does not handle range sentinels nicely
https://github.com/dlang/phobos/pull/8568
Comment #4 by dlang-bot — 2022-09-16T20:26:01Z
@jamesragray created dlang/phobos pull request #8570 "Alternative fix for issue 14543: std.algorithm.searching.until does n…" mentioning this issue:
- Alternative fix for issue 14543: std.algorithm.searching.until does not handle range sentinels nicely.
https://github.com/dlang/phobos/pull/8570
Comment #5 by robert.schadek — 2024-12-01T16:24:30Z