mirror of
https://github.com/dlang/phobos.git
synced 2025-05-10 22:18:03 +03:00
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:
parent
a96255a250
commit
2ef09b95a3
1 changed files with 22 additions and 0 deletions
22
std/string.d
22
std/string.d
|
@ -2943,6 +2943,16 @@ unittest
|
||||||
Returns:
|
Returns:
|
||||||
slice of $(D str) stripped of leading and trailing whitespace.
|
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)
|
auto strip(Range)(Range str)
|
||||||
if (isSomeString!Range ||
|
if (isSomeString!Range ||
|
||||||
isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range &&
|
isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range &&
|
||||||
|
@ -2967,6 +2977,18 @@ auto strip(Range)(Range str)
|
||||||
"hello world");
|
"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
|
@safe pure unittest
|
||||||
{
|
{
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue