Initial commit
This commit is contained in:
commit
61e2e31970
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
Cargo.lock
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "duplicative_match"
|
||||
version = "1.0.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,4 @@
|
|||
# duplicative_match.rs
|
||||
|
||||
A macro that duplicates the provided transformer for all match cases. Useful when types are conflicting but the transformer would work on all of them.
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/// 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
|
||||
}),+
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue