Module alternatively

Source

Functions§

alternatively
Try two argument-less functions of the same function type to generate T, if both fail, return the error of the second attempt (the first error is lost).
alternatively_with_error
Try two approaches to generate T, if both fail, return the error of the second attempt (but f2 could embed the error of the first attempt in that).
alternatively_with_same_error_type
Try two approaches to generate T, if both fail, return the error of the second attempt (but f2 could embed the error of the first attempt in that). Unlike alternatively_with_error, this function forces the error type of both closures to be the same; this is less flexible but has the advantage that the error type for the second closure doesn’t have to be specified if it specifies it as the argument.