You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I have a PR up that provides a .WithType() function that lets you bolt on the missing types to an existing OneOf result object. It makes your case less verbose.
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:
It fails to compile, because it cannot convert from
OneOf<None, Unknown>
toOneOf<None, Unknown, False>
. It makes sense, but considering that I'm returning aFalse
, or aNone
orUnknown
, I think it should work. Instead, I have to manually match the output and return the types, like this, which is pretty redundant:Maybe it's difficult to implement, but IMHO it makes sense that it should work.
The text was updated successfully, but these errors were encountered: