call method

Future<T> call()

Allows calling a Future<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 Future returning an Err value when that Future completes. You can take advantage of this safely via catchResultAsync.

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

int foo = await resultReturn()();

print(foo) // prints: 1

See also: Rust: Result::unwrap()

Implementation

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