Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 519 Bytes

File metadata and controls

19 lines (17 loc) · 519 Bytes

Result-Pattern Example

  • Implicit conversion of Values and Errors to 'Result' objects:
  public static implicit operator Result(TValue value) => new(value);
  public static implicit operator Result(Error error) => new(error);
  • 'Match' function for handling the Result object:
  public TResult Match(
      Func success,
      Func failure)
  {
      return _isSuccess
          ? success(_value!)
          : failure(_error);
  }