Created
June 17, 2020 00:17
-
-
Save altbodhi/b12173317e8b90152438ea03f2a518da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Result<TValue, TError> | |
{ | |
public bool IsOk => this is Ok; | |
public sealed class Ok : Result<TValue, TError> | |
{ | |
public TValue Value { get; } | |
internal Ok(TValue value) => Value = value; | |
} | |
public sealed class Err : Result<TValue, TError> | |
{ | |
public TError Error { get; } | |
internal Err(TError error) => Error = error; | |
} | |
public static Result<TValue, TError> NewErr(TError error) => new Err(error); | |
public static Result<TValue, TError> NewOk(TValue value) => new Ok(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment