or<F> method
Returns res
if the result is Err
,
otherwise returns the Ok
(success) value of this
.
Examples
Basic usage:
Result<int, String> x = Ok(2);
Result<int, String> y = Err('late error');
expect(x.or(y), Ok<int, String>(2));
Result<int, String> x = Err('early error');
Result<int, String> y = Ok(2);
expect(x.or(y), Ok<int, String>(2));
Result<int, String> x = Err('not a 2');
Result<int, String> y = Errint, String>('late error');
expect(x.or(y), Errint, String>('late error'));
Result<int, String> x = Ok(2);
Result<int, String> y = Ok(100);
expect(x.or(y), Ok<int, String>(2));
Implementation
@override
Result<T, F> or<F>(Result<T, F> res) {
return res;
}