GithubHelp home page GithubHelp logo

result's Introduction

result's People

Contributors

2chevskii avatar

Watchers

 avatar

result's Issues

Add easy-to-use type conversion

Description

Users (me, in particular) do not like to write too much of <,,,,> stuff,
so we need to be able to allow automatic type conversion between results with different type arguments when they do not affect it's state (see usage examples)

Usage Example

Result<int, ExampleException> DoStuff() {

  if(allOk) {
    return Result.Ok(42); // Result.Ok here returns Result<int, Exception>, so we convert it to Result<int, ExampleException>
  }
 
  return Result.Err(new ExampleException()); // Result.Err here returns Result<object, ExampleException>, so we convert it to Result<int, ExampleException>
}

Since in C# we are not allowed to make generic type casting operators, or in any other
way cast from base classes and interfaces, we probably need some intermediate type like ConvertibleResult<T> which will only hold it's state and current value, without carrying
information about another possible value type

Alternative

No response

Could you help with a pull-request?

Yup

Async mapping

Description

We need to provide less-nested way to map results which are part of an async flow.
For example: Task<Result<T,E>> should be mappable on the top level (without await or ContinueWith usage)

Maybe we should also provide methods for the invert situation (when Result's T or E are Tasks/ValueTasks)

Usage Example

No response

Alternative

No response

Could you help with a pull-request?

Yup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.