-
Notifications
You must be signed in to change notification settings - Fork 167
Open
Description
I'm liking this library, but I've found a situation which IMHO is a bit annoying and doesn't really make sense. Consider this code:
public async Task<OneOf<None, Unknown, False>> DoThings(Object input)
{
if (something)
{
return new False();
}
OneOf<None, Unknown> result = await OtherMethod(input);
return result;
}
It fails to compile, because it cannot convert from OneOf<None, Unknown> to OneOf<None, Unknown, False>. It makes sense, but considering that I'm returning a False, or a None or Unknown, I think it should work. Instead, I have to manually match the output and return the types, like this, which is pretty redundant:
public async Task<OneOf<None, Unknown, False>> DoThings(Object input)
{
if (something)
{
return new False();
}
OneOf<None, Unknown> result = await OtherMethod(input);
return result.Match<OneOf<None, Unknown, False>>(
none => new None(),
unknown => new Unknown()
);
}
Maybe it's difficult to implement, but IMHO it makes sense that it should work.
cremor and andrewimcclement
Metadata
Metadata
Assignees
Labels
No labels