Open canndrew opened 5 years ago
Do you mean macros expanding to multiple match
arms?
For a single branch this will be automatically supported by https://github.com/rust-lang/rust/issues/54883.
Multiple match arms would be nice, yeah.
@petrochenkov That just supports or-patterns; but afaik you cannot generate match arms (pat (if expr?) => expr
) today...?
This would be useful for this crate: https://github.com/mcmah309/error_set
Currently users have to do this if they want to handle disjointedness with a macro
let val = coerce!(setx => {
Ok(val) => val,
Err(SetX::X) => {}, // handle disjointedness
{ Err(SetX) => return Err(SetY) } // terminal coercion
});
But this would be a lot better if it was possible
let val = match setx {
Ok(val) => val,
Err(SetX::X) => {}, // handle disjointedness
coerce!(Err(SetX) => return Err(SetY)) // terminal coercion
};
Sorry if there's already and issue for this, but I couldn't find one.
On many occasions I've wanted to use macros to generate
match
branches. eg.Is there a reason not to support this?