combine2<T1 extends Object, T2 extends Object> static method
Combines 2 Result outcomes into 1 containing a tuple of their values if all are Ok.
If any are Err, applies onErr
function to combine errors.
See also: combineResult.
Implementation
static Result<(T1, T2)> combine2<T1 extends Object, T2 extends Object>(
Result<T1> r1,
Result<T2> r2, [
@noFutures Err<(T1, T2)> Function(Result<T1>, Result<T2>)? onErr,
]) {
final combined = combineResult<Object>(
[r1, r2],
onErr: onErr == null
? null
: (l) => onErr(l[0].transf<T1>(), l[1].transf<T2>()).transfErr(),
);
return combined.map((l) => (l[0] as T1, l[1] as T2));
}