Return explicitly "empty" MapResult (fail-fast)

Julian Fondren julian.fondren at gmail.com
Thu Jan 1 21:19:22 UTC 2026


On Thursday, 1 January 2026 at 20:00:02 UTC, zhade wrote:
> 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.

It's probably not so clean for your real code, but this works:

```d
return 
typeof(someExpensiveOperation().filter!filterFunc.map!mapFunc).init;
```

I'd be nice if `return typeof(return).init` worked in an `auto` 
function that can infer the type from later in the function.


More information about the Digitalmars-d-learn mailing list