14 lines
452 B
Rust
14 lines
452 B
Rust
/// Duplicates the provided transformer for all match cases. Useful when types are conflicting but the transformer would work on all of them.
|
|
#[macro_export]
|
|
macro_rules! duplicative_match {
|
|
(($subject:expr) { $($pat:pat => $result:expr),+ }, $transformed:ident => $transformer:expr) => {
|
|
match $subject {
|
|
$($pat => {
|
|
let $transformed = $result;
|
|
$transformer
|
|
}),+
|
|
}
|
|
};
|
|
}
|
|
|