Return explicitly "empty" MapResult (fail-fast)
zhade
dragoonzombie at gmail.com
Thu Jan 1 20:00:02 UTC 2026
On Thursday, 1 January 2026 at 19:39:15 UTC, monkyyy wrote:
> On Thursday, 1 January 2026 at 19:30:11 UTC, zhade wrote:
>>
>> auto list = someExpensiveOperation();
>>
>> return list
>> .filter!filterFunc
>> .map!mapFunc;
>> }
>
> oh your looking to mutate the data
>
> Consider my mutmap here if expensive operation is element by
> element:
> https://forum.dlang.org/post/urwssqgafegghncksyio@forum.dlang.org
The actual operations performed by 'filter' and 'map' are not
important. The original question was about how to return an empty
MapResult.
I also thought I could change the 'auto' return type to something
like `InputRange!(Tuple!(string, "value", int, "numLetters"))`
but that didn't work because InputRange != MapResult despite
MapResult effectively being an InputRange.
For now I'll stick with the additional function which applies the
filter and map function.
More information about the Digitalmars-d-learn
mailing list