applay for template function with sumtypes result?
kiriakov
itcraft.letter at gmail.com
Tue Jul 4 15:15:27 UTC 2023
On Tuesday, 4 July 2023 at 14:42:31 UTC, Steven Schveighoffer
wrote:
> On 7/4/23 10:19 AM, kiriakov wrote:
>> On Tuesday, 4 July 2023 at 12:43:19 UTC, Steven Schveighoffer
>> wrote:
>>> On 7/4/23 12:58 AM, kiriakov wrote:
>>
>>> It looks like a type mismatch. The function accepted should
>>> return `Result` but it's returning `ParsResult`.
>>>
>> That's the problem
>>
>> Result(T) = SumType!(ParsResult!T, Err!T)
>>
>
> No, `Result(T)` is its own struct in your example.
> And also, `SumType!(ParsResult!T, Err!T)` is not the same as
> `ParsResult!T`. function pointers must match the return type.
>
> -Steve
I was recommended:
https://forum.dlang.org/thread/iblsgqqafagdgcsafhxv@forum.dlang.org
```
struct Result(T) {
SumType!(ParsResult!T, Err!T) data;
alias data this;
this(Value)(Value value) { data = value; }
}
```
More information about the Digitalmars-d-learn
mailing list