5 ms·
Yes, you'd have to wrap it in a match. But maybe you don't have to. If T1 is the normal case, then there's a type in Rust called Result that handles this kind
by iopq 10y ago
Yes, you'd have to wrap it in a match. But maybe you don't have to.
If T1 is the normal case, then there's a type in Rust called Result that handles this kind of pattern.
fn potentially_failing(thing: Result<Type1, Type2>) {
thing.map(|foo| success_case(foo));
}
this will only execute in the success case and ignore the error case
map_err does the same, but only touching the error case
- flukus 10y agoThanks, that's pretty cool.