std.string.strip_alias_string_fix

make strip take custom types again that have an alias this to string

test stuff
This commit is contained in:
Robert burner Schadek 2015-10-19 01:04:37 +02:00 committed by Robert burner Schadek
parent a96255a250
commit 2ef09b95a3

View file

@ -2943,6 +2943,16 @@ unittest
Returns:
slice of $(D str) stripped of leading and trailing whitespace.
+/
auto strip(Range)(auto ref Range str)
if (!(isSomeString!Range ||
isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range &&
isSomeChar!(ElementEncodingType!Range))
&& is(StringTypeOf!Range))
{
return stripRight(stripLeft(str));
}
/// Ditto
auto strip(Range)(Range str)
if (isSomeString!Range ||
isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range &&
@ -2967,6 +2977,18 @@ auto strip(Range)(Range str)
"hello world");
}
@safe pure unittest
{
static struct TestStruct
{
string s;
alias s this;
}
string s = " hello world ";
assert(strip(s) == strip(TestStruct(s)));
}
@safe pure unittest
{
import std.conv : to;