Why this fires¶
Every possible error must be handled by recover. Guards may fail, so guarded
arms do not establish complete coverage. Integers, strings and any have open
error spaces and require an unguarded wildcard or binding arm.
fn value(result: Result<int, str>) -> int {
result recover { "missing" => 0 } // TE184
}Fix it¶
Add a fallback for the remaining errors, or propagate them from the enclosing function:
fn value(result: Result<int, str>) -> int {
result recover { "missing" => 0, _ => 1 }
}
fn preserve(result: Result<int, str>) -> Result<int, str> {
let value = result recover { error => return Result.Err(error) }
Result.Ok(value)
}For a closed enum or boolean error type, unguarded arms covering every variant or boolean value also establish complete coverage.