rust_like_result library

Classes

Err<T>
Err has Result as superclass. Err() is Result == true See isErr, err getters for getting it's error.
Ok<T>
Represent success result. See isOk, val getters and unpack, for getting it's value. Ok has Result as superclass. Ok(123) is Result == true
Result<T>
Abstract class. Represent common type Result, which may be a Ok or Err. Don't instantiate it. Use implementations: Ok() and Err() instead.

Extensions

ResultPipingAsync on Future<Result<T>>

Functions

testResult<T>(bool test(Result<T>), Result<T> result, String failedTestMsg) Result<T>
Calls test(result) and returns result as is if test return true. Otherwise returns Err(ArgumentError(failedTestMsg)).
tryAsResultAsync<T2>(FutureOr<T2?> f()) Future<Result<T2>>
Calls Function f and awaits it. Returns Ok(...) if all right Returns Err(...) otherwise
tryAsResultSync<T>(T? f()) Result<T>
Calls Function f Returns Err(...) if call result is null or function call throws error. Otherwise seturns Ok(...).