mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
Tweak map's save
Not only does it avoid opAssign issues, but the final code is simpler anyways.
This commit is contained in:
parent
1fa56c676d
commit
9231bdd0b3
1 changed files with 7 additions and 3 deletions
|
@ -560,9 +560,7 @@ private struct MapResult(alias fun, Range)
|
|||
{
|
||||
@property auto save()
|
||||
{
|
||||
auto result = this;
|
||||
result._input = result._input.save;
|
||||
return result;
|
||||
return typeof(this)(_input.save);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -717,6 +715,12 @@ unittest
|
|||
assert(equal(rr[0 .. 5], [1, 4, 9, 16, 0]));
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
struct S {int* p;}
|
||||
auto m = immutable(S).init.repeat().map!"a".save;
|
||||
}
|
||||
|
||||
/**
|
||||
$(D auto reduce(Args...)(Args args)
|
||||
if (Args.length > 0 && Args.length <= 2 && isIterable!(Args[$ - 1]));)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue