call method

Future<T> call()

Allows calling a FutureOr<Result<T, E>> value like a function, transforming it into a Future that unwraps the returned Result value.

Warning: This is an unsafe operation. A ResultError will be thrown if this operation is used on a FutureOr containing an Err value when that FutureOr completes. You can take advantage of this safely via catchResultAsync.

Future<Result<int, String>> resultReturn() {
  return Ok(1);
}

int foo = await resultReturn()();

print(foo) // prints: 1

See also: Rust: Result::unwrap()

Implementation

Future<T> call() async => (await this).unwrap();