Initial commit

This commit is contained in:
Michael Pfaff 2021-05-08 18:46:04 -04:00
commit 61e2e31970
Signed by: michael
GPG Key ID: E53B118B12B5C7F9
4 changed files with 27 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
Cargo.lock

8
Cargo.toml Normal file
View File

@ -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]

4
README.md Normal file
View File

@ -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.

13
src/lib.rs Normal file
View File

@ -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
}),+
}
};
}