Skip to content

Commit

Permalink
Merge pull request #2563 from sinkuu/bycodeunit_slice
Browse files Browse the repository at this point in the history
Fix issue 13535 byCodeUnit doesn't satisfy hasSlicing
  • Loading branch information
dnadlinger committed Sep 27, 2014
2 parents 7c20d04 + 2395bea commit 91322bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion std/utf.d
Expand Up @@ -2725,7 +2725,7 @@ auto byCodeUnit(R)(R r) if (isNarrowString!R)

auto opSlice(size_t lower, size_t upper)
{
return r[lower..upper];
return ByCodeUnitImpl(r[lower..upper]);
}

@property size_t length() const
Expand Down Expand Up @@ -2806,6 +2806,7 @@ pure nothrow @nogc unittest
}
{
auto r = "hello".byCodeUnit();
static assert(hasSlicing!(typeof(r)));
static assert(isBidirectionalRange!(typeof(r)));
auto ret = r.retro;
assert(ret.front == 'o');
Expand All @@ -2814,6 +2815,7 @@ pure nothrow @nogc unittest
}
{
auto r = "κόσμε"w.byCodeUnit();
static assert(hasSlicing!(typeof(r)));
static assert(isBidirectionalRange!(typeof(r)));
auto ret = r.retro;
assert(ret.front == 'ε');
Expand Down

0 comments on commit 91322bc

Please sign in to comment.